Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the event DOMContentReady not happen? [closed]

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?

like image 648
Sascha Mayr Avatar asked Nov 29 '12 19:11

Sascha Mayr


1 Answers

There's no DOMContentReady event.

You want DOMContentLoaded.


document.addEventListener('DOMContentLoaded', function() {alert("good")});

DEMO: http://jsfiddle.net/JQhjj/

like image 88
I Hate Lazy Avatar answered Oct 16 '22 10:10

I Hate Lazy