PDA

View Full Version : Cursor position in firefox...


dep
01-04-2006, 07:17 PM
This is working in IE, but can I get some help with firefox?

var IE = document.all?true:false;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0;
var tempY = 0;

var windowPos = dd.elements["popupWindow"];

// Main function to retrieve mouse x-y pos.s
if (IE) { // grab the x-y pos.s if browser is IE
tempX = event.clientX + document.body.scrollLeft + 20;
tempY = event.clientY + document.body.scrollTop - 32;
windowPos.moveTo(tempX, tempY);
}else{
// ?????????
}

dep

ralph l mayo
01-04-2006, 07:27 PM
The else block:

tempX = (e.pageX < 0) ? 0 : e.pageX;
tempY = (e.pageY < 0) ? 0 : e.pageY;


edit: oops, well you need to pass this function the onmousemove event like thusly:


document.onmousemove = getCoordsFunc;

getCoordsFunc(e)
{ // etc

dep
01-04-2006, 07:35 PM
Awesome.. Thx. Did this:


var IE = document.all?true:false

// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0
var e = new Object();

function popupWindow(e){
var windowPos = dd.elements["popupWindow"];

if (IE) { // grab the x-y pos.s if browser is IE
tempX = event.clientX + document.body.scrollLeft + 20;
tempY = event.clientY + document.body.scrollTop - 32;
windowPos.moveTo(tempX, tempY);
} else { // grab the x-y pos.s if browser is NS
tempX = e.pageX + 20;
tempY = e.pageY - 32;

if (tempX < 0){tempX = 0}
if (tempY < 0){tempY = 0}

windowPos.moveTo(tempX, tempY);
}



....

onClick="javascript:popupWindow(event)

Thanks for the guidance!

dep