
Originally Posted by
martinterry
2. My main point being that only one 'onload' event handler can be used on any page.
That's wholly inaccurate. Whilst it is true that a construct like
HTML Code:
<script type="text/javascript">
window.onload = ...;
</script>
</head>
<body onload="...">
or
HTML Code:
<body onload="...">
<script type="text/javascript">
window.onload = ...;
</script>
will cause only the last set listener to persist, that doesn't prevent any event type from possessing more than one listener.
In decent, modern browsers, all elements have the method addEventListener defined in the W3C DOM 2 Events specification. This allows any number of listeners to be added.
Internet Explorer, which is neither modern nor decent, provides attachEvent. Though this provides similar functionality, it is broken; the this operator - frequently used with event listeners - is set to the global object (window, in scriptable browsers) rather than the element to which the listener is attached.
Even if neither of these features are available, it is trivial to implement one of your own (and it should probably be used in place of attachEvent).
3. I have tested the complete HTML file (as per my second post to this thread) in both IE6 and Netscape 6.2
By that I assume you mean you tested it and it works. Yes, I had a momentary lapse in my recollection of precedence.
Code:
window.onload=init,kissbegin();
Would be parsed as
Code:
(window.onload=init),(kissbegin());
whereas I thought it was
Code:
window.onload=(init,kissbegin());
However, it is still incorrect as kissbegin would be called before the document has finished loading (which was not intended).
Mike
Bookmarks