Question

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/

Was it helpful?

Solution

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top