reload browser ONLY once

Sometimes there's a need to reload a browser only once. This works in IE and FF.
//  Published at: scripts.tropicalpcsolutions.com
var reloaded = false;
var loc=""+document.location;
loc = loc.indexOf("?reloaded=")!=
   -1?loc.substring(loc.indexOf("?reloaded=")+
   10,loc.length):"";
loc = loc.indexOf("&")!=-1?loc.substring(0,loc.indexOf("&")):loc;
reloaded = loc!=""?(loc=="true"):reloaded;

function reloadOnceOnly() {
    if (!reloaded) 
        window.location.replace(
           window.location+"?reloaded=true");
}

//You can call this via the body tag if desired
reloadOnceOnly();

0 comments:

Post a Comment