469,313 Members | 2,261 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,313 developers. It's quick & easy.

Changing the cursor dynamically using JavaScript

I have a figure SVG, and im trying to on mouseover event, change the cursor style to "hand".

I tried to do this:

var figure= document.embeds['SVG'].getSVGDocument().getElementById(elementId);

figure.style.cursor = "hand";

thanks for the help
Feb 14 '08 #1
11 4028
Try using the keyword 'pointer' instead of 'hand'. This is supposed to be the standard and should work on most browser.

Jon
Feb 14 '08 #2
it doesnt work...
and the strange thing is that nothing happens...
no error...and no ...pointer or hand
Feb 14 '08 #3
acoder
16,027 Expert Mod 8TB
What's elementid? Which element are you referring to?
Feb 14 '08 #4
elementid refers to the id of the element
and the element is a rect
Feb 14 '08 #5
acoder
16,027 Expert Mod 8TB
I think you may need the root element before calling getElementById as described here.

If that doesn't work, show the corresponding HTML code.
Feb 15 '08 #6
Here is a description of the SVG file:

[HTML]<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
version="1.1"
baseProfile="full"
id="SVG" image-rendering="optimizeSpeed" width="612" height="800"
viewBox="0 0 612 792" overflow="visible" enable-background="new 0 0 612 792" onload="initSVG()">

<rect id="Planta" x="-70.0" y="60.5" fill="#FFFFFF" width="710" height="655" onclick="onClick(evt)"/>
<g id="Group">
<g id="SmallGroup" onmouseover="ChangeColor(evt)" fill="lightgrey">
<rect id="idRect" name="FigureName" x="408" y="154" fill="silver" width="97" height="5"/>
</g>
</g>
</svg>
[/HTML]

And here is a description of javascript file:

Expand|Select|Wrap|Line Numbers
  1. function ChangeColor(evt)
  2. {
  3.     var elementId = evt.target.getId();
  4.     var figure = document.embeds['SVG'].getSVGDocument().getElementById(elementId);
  5.     figure.setAttribute("opacity",0.25);
  6.  
  7. }
Feb 25 '08 #7
And the opacity works...
So i just want to know how i change the mouse style to "hand" when i pass the mouse over the "rect".

Thanks
Feb 25 '08 #8
where obj = figura in my code;

i have done that...

figura.style.cursor = 'pointer';


and nothing happens...no error and no hand...
Feb 25 '08 #9
gits
5,390 Expert Mod 4TB
where obj = figura in my code;

i have done that...

figura.style.cursor = 'pointer';


and nothing happens...no error and no hand...
just to ensure - i only see figure and no figura in your script?
Feb 25 '08 #10
ok...i have typed wrong here

where obj = figure in my code;

i have done that...

figure.style.cursor = 'pointer';
Feb 25 '08 #11
acoder
16,027 Expert Mod 8TB
Try using setAttribute to set the cursor.
Feb 26 '08 #12

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Geoff Soper | last post: by
2 posts views Thread by malbanese | last post: by
2 posts views Thread by Dominic Myers | last post: by
2 posts views Thread by Jim Frazer | last post: by
7 posts views Thread by Fabien LE LEZ | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.