That is probably so with IE-proprietary attachEvent() method
Right. The test case below gives for IE 6.0 this sequence:
f2()
f3()
f1()
For FF 1.0.7 it gives the original assignment sequence:
f1()
f2()
f3()
So yes, random execution order seems to be a "feature" of attachEvent
only. But at least it's properly documented on MSDN.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script type="text/javascript">
function init() {
var obj = document.getElementById('test');
/*@cc_on
@if (@_jscript)
with (obj) {
attachEvent('onclick',f1);
attachEvent('onclick',f2);
attachEvent('onclick',f3);
}
@else @*/
with (obj) {
addEventListener('click',f1,false);
addEventListener('click',f2,false);
addEventListener('click',f3,false);
}
/*@end @*/
}
function f1() {
alert('f1');
}
function f2() {
alert('f2');
}
function f3() {
alert('f3');
}
window.onload = init;
</script>
<style type="text/css">
body {background-color: #FFFFFF}
var {font: normal 10pt Verdana, Geneva, sans-serif;
color: #0000FF; text-decoration: underline;
cursor: hand; cursor

ointer}
</style>
</head>
<body>
<noscript>
<p><font color="#FF0000"><b>JavaScript disabled:-</b><br>
<i><u>italized links</u></i> will not work properly</font></p>
</noscript>
<p>
<var id="test">Test</var>
</p>
</body>
</html>