Discussion:
window.event.srcElement is null
(too old to reply)
zino66
2009-12-11 16:51:01 UTC
Permalink
I have the following:

the HTML page has this DIV:
..... .... .. .
<div id="myTask">
... .. . . ...



the javascript file is:

window.onload=function()
{
document.getElementById("myTask").onmouseover=tab_mouseover;
tab_mouseover.apply(document.getElementById("myTask"));
}



function tab_mouseover(evt)
{
var evt = (evt) ? evt : ((window.event) ? event : null);
var from = (window.event) ? evt.srcElement : evt.target; //generate error
var to = (evt.relatedTarget) ? evt.relatedTarget : evt.toElement;
while (to && to != from && to.nodeName != 'BODY'){ to = to.parentNode; }
if (to == from) return;
}

the "evt.srcElement" is always null. How can I solve it?
I tried it in IE 6 and IE8

thanks for help
rob^_^
2009-12-11 20:43:46 UTC
Permalink
use the this keyword.

don't know why your not using
myTask.onmoseover=function()
....

What are other sites doing?

<noscript></noscript>

Regards.
Post by zino66
..... .... .. .
<div id="myTask">
... .. . . ...
window.onload=function()
{
document.getElementById("myTask").onmouseover=tab_mouseover;
tab_mouseover.apply(document.getElementById("myTask"));
}
function tab_mouseover(evt)
{
var evt = (evt) ? evt : ((window.event) ? event : null);
var from = (window.event) ? evt.srcElement : evt.target; //generate error
var to = (evt.relatedTarget) ? evt.relatedTarget : evt.toElement;
while (to && to != from && to.nodeName != 'BODY'){ to = to.parentNode; }
if (to == from) return;
}
the "evt.srcElement" is always null. How can I solve it?
I tried it in IE 6 and IE8
thanks for help
Loading...