Hi everyone,
I'm trying find an explanation to the following question, I looked around and haven't found any awnser so far: What is the the difference between the Simon Willison's code for the AddLoadEvent function and the load function from jQuery?
Here are the links:
1 ) AddLoadEvent code : http://simonwillison.net/2004/May/26/addLoadEvent/
2 ) .load function jQuery see api load from jQuery
-----------Case# 1 (jQuery .load function)--------------
remplaceMissingImage(){
//run code...
}
$(window).load(function () {
// run code
remplaceMissingImage();
});
-----------or Case# 2 (AddEventLoad - JS)---------------
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
remplaceMissingImage(){
//run code
}
addLoadEvent(remplaceMissingImage());
Q: Would these two pieces of code do the same thing?
$(window).load(function()) vs AddLoadEvent
Thanks in advance, sethier