By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,688 Members | 1,936 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,688 IT Pros & Developers. It's quick & easy.

Why Doesn't This Work In Firefox?

P: n/a
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!
Jun 27 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
jo*********@topscene.com 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
--
Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.