HTML and CSS Reference
In-Depth Information
Figure 15.44 The event listener was removed. The mouse event doesn't occur.
15.9.4 Event Listeners with Microsoft Internet Explorer
Microsoft, too, has developed an event registration model. It looks similar to W3C's, but
has some important differences. To write cross-platform compatible code, you can test
for both. See Example 15.23.
The attachEvent() Method. The attachEvent() method is an IE5+ proprietary
equivalent of addEventListener() . The method is attached to the object for which the
event is intended. The parameters include the event type and a function. Unlike the
W3C model, the event type parameter must include the on prefix (i.g., onload , onclick
etc.). If you forget this little, but important point, the method will not work!
object.attachEvent(eventType, function)
if (window.attachEvent){
myDiv.attachEvent("onclick", changeColor);
Search WWH ::

Custom Search