• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 575
  • Last Modified:

NaN in Netscape and Firefox but not in IE

The following code generates NaN for the y co-ordinate in Netscape and Firefox browsers but in IE it generates a number value for the y co-ordinate.
In all browsers the code generates a number value for the x co-ordinate - no problem.
Can anyone advise please?

<script type="text/javascript">

window.onload = init;

function init()
  intCoordinateSequence = 1;
  obj = document.getElementById("imgMap2");
  obj.onclick = fillCoordinateFields3;

function fillCoordinateFields3(e) {
     var x = parseInt(window.event? event.offsetX + getX(obj): e.pageX);
     var y = parseInt(window.event? event.offsetY + getY(obj): e.pagey);
     switch (intCoordinateSequence) {
          case 1:
               document.frmCoordinates.X1.value = x - getX(obj);
               document.frmCoordinates.Y1.value = y - getY(obj);

               document.getElementById("pointer1").style.left = (x-3) + "px";
               document.getElementById("pointer1").style.top =  (y-3) + "px";
               document.getElementById("pointer1").style.visibility = 'visible';
          default: ;

function getX(obj)
  return( obj.offsetParent==null ? obj.offsetLeft : obj.offsetLeft+getX(obj.offsetParent) );

function getY(obj)
  return( obj.offsetParent==null ? obj.offsetTop : obj.offsetTop+getY(obj.offsetParent) );

  • 2
1 Solution
Shouldn't "e.pagey" be "e.pageY" ?

wiseinfoAuthor Commented:
Many thanks Roonaan

Your eyes are better than ours
Thanx to you too.

Fresh eyes always help, when things get confusing ;-)


Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now