Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<!DOCTYPE html>
<html>
<head>
<title>DOM Event test: order of execution</title>
<script type="text/javascript">
// W3C DOM Event test
(function() {
if (document.addEventListener) {
document.addEventListener('click', handler1, false);
document.addEventListener('click', handler2, false);
document.addEventListener('click', handler3, false);
} else {
document.attachEvent('onclick', handler1);
document.attachEvent('onclick', handler2);
document.attachEvent('onclick', handler3);
}
function handler1(e) {
alert("* DOM order 1");
}
function handler2(e) {
alert("* DOM order 2");
}
function handler3(e) {
alert("* DOM order 3");
}
})();
</script>
</head>
<body>
<p>Click anywhere in the document; expected result order 1, 2, 3. All browsers except IE 6 / 7 / 8 !</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment