Any ideas why this code doesn’t work?
<html><head>
<script type="text/javascript">
document.onDOMContentLoaded=function(){
alert('aaaaaaaaaaaaaa');
}
</script>
</head>
<body>
<div id="mydiv"></div>
</body>
</html>
onDOMContentLoaded is expected to triogger when the webpage is loaded and make that alert but it doesn’t work dunno why
You should be binding to the event with
addEventListener:http://jsfiddle.net/qHa4T/1
Keep in mind that both
addEventListenerandDOMContentLoadedwon’t work with IE8 and below.