NaN in Netscape and Firefox but not in IE

Posted on 2004-11-02
Last Modified: 2012-06-21
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") =  (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) );

Question by:wiseinfo
    LVL 49

    Accepted Solution

    Shouldn't "e.pagey" be "e.pageY" ?


    Author Comment

    Many thanks Roonaan

    Your eyes are better than ours
    LVL 49

    Expert Comment

    Thanx to you too.

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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: HTML5 for Beginning Beginners

    Are you looking for an efficient introduction to HTML5? Have you tried other HTML5 courses and found them too complex? Do you need just the basics of HTML5 to use with Wordpress or other content management system? If you said yes to any of these questions, this course is for you.

    This article shows how to read a single webpage's HTML into a string variable, and it also shows how to automate a sequence so you can read and process a list of webpages.  I was tasked with reading and parsing a series of webpages to collect some s…
    Article by: DanRollins
    This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (, we'll extend the program by adding a depth-…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now