
Originally Posted by
Twey
Firstly, why does it only happen with IE?
Bubbling? It occurs in all browsers.
Secondly, how exactly should I use these?
Perhaps you should first state what you're trying to do.
Comparing with event.target works fine in everything but IE (in other words, makes no difference at all); comparing with event.srcElement always seems to return false
It won't.
Code:
function doStuff(element, event) {
var target = event.target || event.srcElement;
if (target) {
alert('Node: ' + target.nodeName
+ '\nDispatcher is list: ' + (element == target));
}
}
HTML Code:
<ul style="border: 1px solid; padding: 1em;" onmouseout="doStuff(this, event);">
<li style="border: 1px solid;">A</li>
<li style="border: 1px solid;">B</li>
</ul>
Use the keyboard to dismiss the dialogue box. You will see the pattern 'UL', 'LI', 'LI', 'UL', and 'true', 'false', 'false', 'true'. It will be different with IE in that no event will be triggered by the lower padding region of the list, so one of the 'UL' and 'true' results will be missing; when depends on the direction of the mouse over the list.
Mike
Bookmarks