Your first problem:
You have configured JSFiddle to run your JS when the load
event fires.
Consequently, when the load
event fires, you bind another load
event handler.
Your new load
event handler is never called because the load
event has already fired.
Change the menu option to one of the "No Wrap" approaches.
Your second problem:
The load
event fires on the window
object, not the body
element.
You need to assign the property to the right place.
onload = function(){
alert("LOADED!");
}
Such: https://jsfiddle.net/n5jb0159/5/
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…