Why Doesn't This Work In Firefox?

J

joey.powell

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!
 
Á

Álvaro G. Vicario

(e-mail address removed) 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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,477
Members
44,898
Latest member
BlairH7607

Latest Threads

Top