On Page Load

Anything not fitting into other categories

On Page Load

Postby produke » 01 Nov 2006 10:29

Loads the javascript function (fn) AFTER the page loads.

Code: Select all
//------------------------------------
// addLoadListener
function addLoadListener(fn){
    if(typeof window.addEventListener !='undefined')    window.addEventListener('load',fn,false);
    else if(typeof document.addEventListener !='undefined')    document.addEventListener('load',fn,false);
    else if(typeof window.attachEvent !='undefined')    window.attachEvent('onload',fn);
    else{
        var oldfn=window.onload
        if(typeof window.onload !='function')    window.onload=fn;
        else    window.onload=function(){oldfn();fn();}
    }
}
// addLoadListener
//====================
User avatar
produke
 
Posts: 242
Joined: 25 Sep 2006 04:48

Postby produke » 05 Jan 2007 03:54

You can use it like this...

Code: Select all
addLoadListener(init_cookies);
addLoadListener(init_dd);
addLoadListener(init_preload);
addLoadListener(init_formSend);
addLoadListener(init_flash);
addLoadListener(init_previewVideos);
addLoadListener(init_postload);
addLoadListener(init_getNews);




/*-----------------------------------------------------[ START INIT FUNCTIONS ]
*/


//------------------------------------
// init_preload
function init_preload(){
    REFF=document.referrer;
    pageTitle=document.title.substring((document.title.indexOf("»")+2),((document.title.indexOf("|")-1)));
    land=window.location.href;
    pagePath=window.location.pathname;
    _uacct = "UA-879836-1";
    urchinTracker();
    //gi('SW').innerHTML='<pre>'+pageTitle+'<br />'+land+'<br />'+pagePath+'</pre>';
}
// init_preload
//====================

User avatar
produke
 
Posts: 242
Joined: 25 Sep 2006 04:48


Return to Main



Who is online

Users browsing this forum: Mesmer7