Hi
I'm new to Javascript and trying to get a layer div to display next to the mouse cursor. My code works great in IE and Chrome browsers but won't work in Firefox. If I remove the part bewteen the asterisks which gets the cursor position it works fine, but obviously doesn't display the div next to the mouse
Any help is really appreciated
Thanks
Chris
:)
function displayPupCurrDiv(url, target, e) {
obj1 = document.getElementById(target);
if (obj1.style.display == "none"){
// ********************************************
e = e || window.event;
var cursor = {x:0, y:0};
if (e.pageX || e.pageY) {
cursor.x = e.pageX;
cursor.y = e.pageY;
}
else {
var de = document.documentElement;
var b = document.body;
cursor.x = e.clientX +
(de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
cursor.y = e.clientY +
(de.scrollTop || b.scrollTop) - (de.clientTop || 0);
}
obj1.style.top = (cursor.y - 100) + 'px';
obj1.style.left = (cursor.x + 10) + 'px';
// ********************************************
obj1.style.display = "";
obj1.innerHTML = '<br> Fetching data...';
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
if (req != undefined) {
req.onreadystatechange = function() {finishPupCurrDiv(url, target);};
req.open("GET", url, true);
req.send("");
}
}
else {
obj1.style.display = "none";
}
}