Entry
Does NN6 have a property similar to IE4+'s document.activeElement?
Mar 23rd, 2001 06:08
Martin Honnen,
That property or a similar doesn't exist in NN6's DOM. But you can use
JavaScript to set
document.activeElement
in NN6, at least for those elements which support onfocus:
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript1.5">
window.onload = init;
function init () {
document.activeElement = document.body;
var all = document.body.getElementsByTagName('*');
for (var i = 0; i < all.length; i++) {
var functionBody = 'document.activeElement = this;';
var oldOnFocus = all[i].getAttribute('onfocus');
if (oldOnFocus)
functionBody += oldOnFocus;
all[i].onfocus = new Function ('event', functionBody);
}
}
</SCRIPT>
</HEAD>
<BODY ID="theBody">
<DIV STYLE="background-color: green;"
ONMOUSEOVER="alert(document.activeElement.id)">
mouseover here to show activeElement
</DIV>
<A ID="aLink" HREF="http://javascript.faqts.com">JavaScript FAQTs</A>
<INPUT TYPE="button" ID="aButton" VALUE="Kibology"
ONCLICK="alert('Kibology');"
>
<P ID="aP">
All for Kibology.
</P>
</BODY>
</HTML>