January 9, 2001 - Multiple Events in IE 5.x
January 9, 2001 Multiple Events in IE 5.x Tips: January 2001
Yehuda Shiran, Ph.D.
|
attachEvent()
method for that:
document.element.attachElement(eventNameString, functionPointer)
The following code creates a button and attaches two onclick
event handlers to it:
<FORM>
<INPUT ID="counter1" STYLE="position:relative; left:10px" TYPE="button" VALUE="Click Me in IE 5.x">
</FORM>
<SCRIPT LANGUAGE="JavaScript">
<!--
var obj = document.getElementById('counter1');
var xlocation = parseInt(obj.style.left);
document.getElementById('counter1').attachEvent("onclick", firstClick);
document.getElementById('counter1').attachEvent("onclick", secondClick);
function firstClick() {
alert("first click");
}
function secondClick() {
alert("second click");
}
// -->
</SCRIPT>
Play around with it now in Internet Explorer 5.x. Observe the two alert boxes for the two event handlers:
For more on the Internet Explorer event model, go to Column 10, The Internet Explorer Event Model.