[thelist] Thorny Javascript Issue with onMouseOver and Event Object....
Anthony Baratta
Anthony at Baratta.com
Thu Jan 26 11:44:18 CST 2006
Ok..
Well thorny for me this week. ;-)
Here's the background:
I have a mouse over event that launches a javascript function. That
works fine no issues - basic stuff. But now I need to know the location
of the mouse cursor when the event is fired. Here Firefox and IE (our
two target browsers for now) have diverging issues.
Firefox needs the event object passed into the function, IE appears to
ignore that (null object result), and needs the event object created
manually in the function, or pass the attributes of the event directly
via the function call. Of course FireFox blows up if you pass the
attributes of the event object directly to the function.
So, even with that - I've sort of got an event object working but I
can't find the coordinates of the mouse. Here's the code I currently have:
onmouseover:
this.style.cursor='pointer';
showColorCombo(##, event);
function showColorCombo(cID, evt)
{
if (parseInt(cID) != NaN)
{
var xmlhttp = getNewXmlHttpObject();
uri = "./ajax.aspx?a=colorCombo&cID=" + cID;
xmlhttp.open("GET", padURI(uri), true);
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4)
{
document.getElementById("divText").innerHTML = xmlhttp.responseText;
if (ie) { evt = window.event }
if (evt)
{
var x = evt.screenX+25;
var y = evt.screenY;
layerOn("pop_colorCombo", x, y);
}
}
}
xmlhttp.send(null);
}
}
The above does not fail with Firefox, but the dHTML "layer" does not
appear in the location I want (e.g. relative to the mouse cursor)
because the event object does not have values for the screenX/Y properties.
With IE, the evt object is "null" and I can't even get the layer to show
- even in the wrong location like Firefox.
Thoughts, ideas, BBQ recipes?
More information about the thelist
mailing list