...

View Full Version : DOM load help



ninnypants
01-27-2009, 03:02 AM
I've been looking for a script to tell when the DOM content of the page has loaded, and I found this script that does the trick but I'd like to know how some of it works.

what is the reason for wrapping everything in the parentheses "()" I know it groups sections of code or requirements for if statements, but what is the application here

when argument.callee is called is it calling it's containing function or a different one


(function(i) {
var u =navigator.userAgent;
var e=/*@cc_on!@*/false;
var st = setTimeout;
if(/webkit/i.test(u)){
st(
function(){
var dr=document.readyState;
if(dr=="loaded"||dr=="complete"){
i()
}else{
st(arguments.callee,10);
}
}
,10);
}else if((/mozilla/i.test(u)&&!/(compati)/.test(u)) || (/opera/i.test(u))){
document.addEventListener("DOMContentLoaded",i,false);
} else if(e){
(
function(){
var t=document.createElement('doc:rdy');
try{
t.doScroll('left');
i();
t=null;
}catch(e){
st(arguments.callee,0);
}
}
)();
}else{
window.onload=i;
}
})(init);

thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum