Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mouseover image

Status
Not open for further replies.

ozane

Technical User
Feb 3, 2005
57
TR
hi, i have an image on my aspx page. i wantto see the coordinates of that image while roaming on the image dynamically. and when i mouseover i want to change the cursor. so, i could achieved this. but when i want to mouseout from the image, anywhere on the page, i dont want to see coordinates anymore and set the cursor default.
what should i do to do that when mouse is out of image. here is my code:

function show() {
var x=0
var y=0
x=event.clientX+document.body.scrollLeft
y=event.clientY+document.body.scrollTop
window.status=x + " " + y
document.body.style.cursor='crosshair'
document.onmousemove=show;
return true
}

what to do for onmouse. i tried to add
document.onmouseout=....; with a function but it is working just outside the window :)

thanks
 
instead of setting your cursor with javascript, set it with css:

Code:
<img ... style="cursor: crosshair;" />

*cLFlaVA
----------------------------
[tt]I already made like infinity of those at scout camp...[/tt]
beware of active imagination: [URL unfurl="true"]http://www.coryarthus.com/[/url]

BillyRayPreachersSonIsTheLeetestHax0rDude
[banghead]
 
so what about coordinates for mouseover and out?
 
you say your coordinate display is working. so you want to remove the coords...

Code:
<img onmouseout="window.status='';" />

*cLFlaVA
----------------------------
[tt]I already made like infinity of those at scout camp...[/tt]
beware of active imagination: [URL unfurl="true"]http://www.coryarthus.com/[/url]

BillyRayPreachersSonIsTheLeetestHax0rDude
[banghead]
 
and i would put the call to onmousemove in the image, not in the document.

*cLFlaVA
----------------------------
[tt]I already made like infinity of those at scout camp...[/tt]
beware of active imagination: [URL unfurl="true"]http://www.coryarthus.com/[/url]

BillyRayPreachersSonIsTheLeetestHax0rDude
[banghead]
 
ok last question...
i am running javascript from asp.net for image with

imgMap.Attributes.Add("onMouseOver", "javascript:show()")

i think i should stop that script when mouseout from image. is there a way to stop using script...
it seems really stupid question, but i am beginner ;)
 
x=event.clientX+document.body.scrollLeft

is giving me the coordinates of page.

how can i get the coordinates of the "<asp:imgage" control?
 
how can i get the coordinates of the "<asp:imgage" control?

No idea - but if you tell us the client-side element that is output to the page, I'm sure we can help.

Client-side questions about server-side elements are never easy to answer.

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top