Why Doesn't This Work In Firefox?

Discussion in 'Javascript' started by joey.powell@topscene.com, May 22, 2008.

  1. Guest

    Hello,

    I am working on a mapping application where I need to be able to
    determine the mouse cursor position on the browser screen. I have done
    a lot of reading about this...apparently one should
    use .pageX / .pageY for Firefox and e.clientX / e.clientY for Internet
    Explorer.

    In my page I have the following code segment. It works great for IE,
    but it always hangs (does not advance to the next line of code) on
    reference to .pageX or .pageY when using Firefox. The version I am
    using is 2.0.0.11. This does not make any sense to me as every example
    I have seen involves using .pageX and .pageY with Firefox.

    What is causing it to hang?

    function GetMouse(e)
    {
    if(!e) { e=window.event; }
    //GETS TO HERE
    if(!e || (typeof(e.pageX)!='number' && typeof(e.clientX)!
    ='number')) { xcoord=0;ycoord=0; }
    if(typeof(e.pageX)=='number' && typeof(e.pageY)=='number')
    {
    //NEVER MAKES IT HERE
    var xcoord=e.pageX;
    var ycoord=e.pageY;
    }
    //OR HERE!
    ....more code...

    Please tell me what I am doing wrong here. Thanks!
     
    , May 22, 2008
    #1
    1. Advertising

  2. escribió:
    > In my page I have the following code segment. It works great for IE,
    > but it always hangs (does not advance to the next line of code) on
    > reference to .pageX or .pageY when using Firefox. The version I am
    > using is 2.0.0.11. This does not make any sense to me as every example
    > I have seen involves using .pageX and .pageY with Firefox.


    Current version is 2.0.0.14 so you've missed 3 updates :-?


    > What is causing it to hang?
    >
    > function GetMouse(e)
    > {
    > if(!e) { e=window.event; }
    > //GETS TO HERE
    > if(!e || (typeof(e.pageX)!='number' && typeof(e.clientX)!
    > ='number')) { xcoord=0;ycoord=0; }
    > if(typeof(e.pageX)=='number' && typeof(e.pageY)=='number')
    > {
    > //NEVER MAKES IT HERE
    > var xcoord=e.pageX;
    > var ycoord=e.pageY;
    > }
    > //OR HERE!
    > ...more code...


    I get an JavaScript exception but it doesn't hang in my computer:

    e has no properties
    if(typeof(e.pageX)=='number' && typeof(e.pageY)=='number')

    I suggest you enable automated updates and see if hanging persists.
    Also, get Firebug extension so you can debug more easily.


    --
    -- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
    -- Mi sitio sobre programación web: http://bits.demogracia.com
    -- Mi web de humor al baño María: http://www.demogracia.com
    --
     
    Álvaro G. Vicario, May 23, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,037
    Smokey Grindel
    Dec 2, 2006
  2. John Kotuby
    Replies:
    5
    Views:
    607
    John Kotuby
    Sep 25, 2008
  3. John Kotuby
    Replies:
    0
    Views:
    371
    John Kotuby
    Sep 24, 2008
  4. Replies:
    3
    Views:
    140
  5. Man-wai Chang

    Why doesn't this page work with Firefox?

    Man-wai Chang, May 1, 2007, in forum: Javascript
    Replies:
    0
    Views:
    81
    Man-wai Chang
    May 1, 2007
Loading...

Share This Page