Reply
Javascript MouseMove event, another cross-browser mess.
Old 10-06-2004, 09:42 AM Javascript MouseMove event, another cross-browser mess.
Minaki's Avatar
Defies a Status

Posts: 1,626
Location: Guildford, UK
Hi,

I have this code which is attached to a simple DIV element (with no CSS Styles or anything)

Code:
<div id="divImage">
<img src="" alt="Map" name="imgMap" id="imgMap" />
</div>
Code:
function MapMouseMove(e) {
	if (isIE) {
	 OffsetX = window.event.offsetX;
	 OffsetY = window.event.offsetY;
	} else {
	 OffsetX = e.pageX - document.getElementById("divImage").offsetLeft; 
	 OffsetY = e.pageY - document.getElementById("divImage").offsetTop;	
	}
	GetXY(OffsetX, OffsetY);
	if ((MouseX != -1) && (MouseY != -1) && (ShowCoords == true))
	 document.getElementById("txtCoords").value = Math.round(MouseX / 1000) + 'N, ' + Math.round(MouseY / 1000) + 'E';
	else
	 document.getElementById("txtCoords").value = '';
   }
Works fine in IE, however in FireFox, document.getElementById("divImage").offsetLeft and offsetTop are always 2, and not the respective distances of the Div from the top left of the page. This script worked OK in another layout using tables, etc, however I have needed to change the layout.

What I want is for OffsetX and OffsetY to be equal to where the mouse is over the image. Is there any alternate method I can use?
__________________
Minaki Serinde MCP
"Wow, Linux is nearly on-par with Windows ME!"
Inoxia Pyrotechnics Supplies | Surrey Angels Cheerleading Squad
Minaki is offline
Reply With Quote
View Public Profile Visit Minaki's homepage!
 
When You Register, These Ads Go Away!
Reply     « Reply to Javascript MouseMove event, another cross-browser mess.
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11525 seconds with 12 queries