0

The question is pretty simple: why is nither of those are working when they should? Tried in latest chrome and FF

document.addEventListener("DOMContentLoaded", function() {
  alert("window on domcontentready");
}, false);

window.onload = function() {
  alert("window on load");
}

http://jsfiddle.net/FHHgA/4/

ilyo
  • 35,851
  • 46
  • 106
  • 159

2 Answers2

1

The JavaScript is loaded on onload (inside jsfiddle), so onload won't fire, because it already fired. Switch onload to no wrap - in <head>.

Moritz Mahringer
  • 1,240
  • 16
  • 28
0

Create a blank html file and paste in your js, opening the html file will show the alerts. However it doesnt seem to display the alerts in in JSFiddler.

Waqar
  • 758
  • 4
  • 15