Forum Moderators: coopster
I really just pieced this together from other sites
//enter refresh time in "minutes:seconds" Minutes should range from 0 to inifinity. Seconds should range from 0 to 59
var limit="05:00"
if (document.images){
var parselimit=limit.split(":")
parselimit=parselimit[0]*60+parselimit[1]*1
}
function beginrefresh(){
if (!document.images)
return
if (parselimit==1)
window.location.reload()
else{
parselimit-=1
curmin=Math.floor(parselimit/60)
cursec=parselimit%60
if (curmin!=0)
curtime=curmin+" minutes and "+cursec+" seconds left until page refresh!"
else
curtime=cursec+" seconds left until page refresh!"
window.status=curtime
setTimeout("beginrefresh()",1000)
}//else
}//beginrefresh
var RecoverScroll=/*28432953204368616C6D657273*/
{
timer:null, x:0, y:0,cookieId:"RecoverScroll", dataCode:0, DEBUG:false,
init:function(pageName)
{
var offsetData;
if( document.documentElement )
this.dataCode=3;
else
if( document.body && typeof document.body.scrollTop!='undefined' )
this.dataCode=2;
else
if( typeof window.pageXOffset!='undefined' )
this.dataCode=1;
if(pageName)
this.cookieId=pageName;
if((offsetData=this.readCookie(this.cookieId))!=""
&& (offsetData=offsetData.split('¦')).length==4
&& !isNaN(offsetData[1]) && !isNaN(offsetData[3]))
{
window.scrollTo(offsetData[1],offsetData[3]);
if(this.DEBUG)
document.title=offsetData;
}
this.record();
this.addToHandler(window,'onscroll',function(){RecoverScroll.reset()});
},
reset:function()
{
clearTimeout(this.timer);
this.timer=setTimeout("RecoverScroll.record()",500);
},
record:function()
{
var cStr;
this.getScrollData();
this.setTempCookie(this.cookieId, cStr='x¦'+this.x+'¦y¦'+this.y);
if(this.DEBUG)
window.status=cStr;
},
setTempCookie:function(cName, cValue)
{
document.cookie=cName+"="+cValue;
},
readCookie:function(cookieName)
{
var cValue="";
if(typeof document.cookie!='undefined')
cValue=(cValue=document.cookie.match(new RegExp(cookieName+'=([^;]+);?'))) ? cValue[1] : "";
return cValue;
},
getScrollData:function()
{
switch( this.dataCode )
{
case 3 : this.x = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);
this.y = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
break;
case 2 : this.x=document.body.scrollLeft;
this.y=document.body.scrollTop;
break;
case 1 : this.x = window.pageXOffset; this.y = window.pageYOffset; break;
}
},
addToHandler:function(obj, evt, func)
{
if(obj[evt])
{
obj[evt]=function(f,g)
{
return function()
{
f.apply(this,arguments);
return g.apply(this,arguments);
};
}(func, obj[evt]);
}
else
obj[evt]=func;
}
}
window.onload=beginrefresh;
RecoverScroll.addToHandler(window,'onload',function(){RecoverScroll.init("yourPage.php")});
Tada!