Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kdahlhaus/3f7c803f7e147d6c28951d927c998df4 to your computer and use it in GitHub Desktop.
Save kdahlhaus/3f7c803f7e147d6c28951d927c998df4 to your computer and use it in GitHub Desktop.
Auto-refresh bookmarklet
/* origin: http://www.google.com/support/forum/p/Chrome/thread?tid=1a37ccbdde5902fd&hl=en
this version restores vertical scroll position after reload */
javascript:
timeout=prompt("Set timeout [s]");
current=location.href;
if(timeout>0) {
setTimeout('reload()',1000*timeout);
}
else
{
location.replace(current);
}
var called=false;
function reload(){
var y = 0;
if (called)
{
y = window.frames[0].scrollY;
}
else
{
y = window.scrollY;
called=true;
}
setTimeout('reload()',1000*timeout);
fr4me='<frameset cols=\'*\'><frame src=\''+current+'\' onload=\'setTimeout("window.frames[0].scrollTo(0,'+y+');", 100)\' /></frameset>';
with(document){write(fr4me);void(close())};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment