I tried to call a function, when all DOM elements in the page are loaded, like this:
document.addEventListener('DOMContentReady', function() {alert("good")});
It’s an HTML file with an empty body and empty head except this JavaScript and nothing happens even if the browser finished loading. What could be wrong here? And are there other ways to do this?
There’s no
DOMContentReadyevent.You want
DOMContentLoaded.DEMO: http://jsfiddle.net/JQhjj/