if i write this
$(document).ready( function () {
alert("bla1");
});
$(document).ready( function () {
alert("bla2");
});
All good, two alert occurs, but if code is
window.onload = function () {
alert("bla1");
}
window.onload = function () {
alert("bla2");
}
second alert not happened, tell someone please, why 2 or more window.onload is wrong?
You assign something to it. You then assign something else to it and overwrite what is there before.
If you want to assign event handlers non-destructively, use
addEventListener. You will need to use compatibility methods to support Old-IE. Such methods are built into jQuery via theonmethod.