I'm using Netscape 6.1, and find that offsetTop/Left are undefined. See the following for the sample script in which I determined it was unavailable.
www.xmission.com/~dgoddard
The following is the contents of the page at the URL above:
<HTML><HEAD>
<SCRIPT language=JavaScript>
//This captures user's mouse clicks inside an image, both graphically by placing "dots" there, as well as via coordinates which are displayed in a form field.
var dots = ["dot0", "dot1", "dot2", "dot3", "dot4", "dot5", "dot6", "dot7", "dot8", "dot9", "dot10"];
var xycoords = ""; //Will hold coordinates string collected from mouse events
function placeDot(event)
{
xPosition = event.offsetX?(event.offse
yPosition = event.offsetY?(event.offse
//Populate coords string.
if (!(xycoords=="")) {
xycoords=xycoords + ", ";
}
xycoords += (xPosition) + ',' + (yPosition);
document.getElementById("c
window.status=xycoords;
// Loop until find first free dot for display, then give it the mouse event's coordinates.
found=false;
for (i=0; i<dots.length; i++) {
if (document.getElementById(d
//window.status+=dots[i]+"
found=true;
break;
}
}
if (found) {
document.getElementById(do
document.getElementById(do
document.getElementById(do
//return ; //uncomment this to prevent the alert box below from showing
}
//The following is simply for testing, creating an alert that shows available and unavailable properties
alert('\n ?event.offsetY:'+event.off
'\n else event.clientY:'+event.clie
'\n minus document.getElementById("i
'\n my calculated yPosition:'+yPosition+
'\n document.getElementById("i
'\n event.target.offsetY:'+eve
'\n event.offsetY:'+event.offs
'\n event.offsetTop:'+event.of
'\n clientY'+document.getEleme
'\n clientTop'+document.getEle
'\n clientLeft'+document.getEl
}
</SCRIPT>
</HEAD>
<BODY bgcolor="999999">
Click inside the grey box, then scroll a little and repeat.
<p> </p><p> </p>
<FORM name="myform" method=post encType=multipart/form-dat
<INPUT size=100 name="coords" id="coords" value="">
<DIV id="imgDiv" style="POSITION:relative; visibility:visible; left:0; top:0;" width=300 height=300 onClick="placeDot(event)">
<IMG SRC="greybox.gif" width=300 height=300 border=1 id="clickfield" style="visibility:visible;
<script>
for (i=0;i<dots.length;i++) {
document.write('<img src="dot.gif" id='+dots[i]+' style="position:absolute; visibility:hidden; z-index:2;">');
}
</script>
</DIV>
<input type="Submit" name="submit" value="Submit">
</FORM>
<p> </p><p> </p>
</BODY></HTML>
Main Topics
Browse All Topics





by: CJ_SPosted on 2001-09-16 at 03:38:12ID: 6485572
instead of offsetLeft, use scrollLeft. Same for offsetTope.
Regards,
CJ