After 6 years I have a solution for this!
The answer is inspired by the other answers here.
Edub's answer didn't work for me, it reloaded the page over and over, and didn't observe setInterval
's duration parameter. I don't understand why Edub's answer doesn't work as expected.
This works for me in Chrome 67:
javascript:document.getElementsByTagName("body")[0].innerHTML = "<iframe id=\"testFrame\" src=\""+window.location.toString()+"\" style=\"position: absolute; top:0; left:0; right:0; bottom:0; width:100%; height:100%;\"><\/iframe>";reloadTimer = setInterval(function(){ document.getElementById("testFrame").src=document.getElementById("testFrame").src },10000)
Formatted version:
document.getElementsByTagName("body")[0].innerHTML =
"<iframe id=\"testFrame\"
src=\"" + window.location.toString() + "\"
style=\"position: absolute; top:0; left:0; right:0; bottom:0; width:100%; height:100%;\">
<\/iframe>";
reloadTimer = setInterval(
function(){
document.getElementById("testFrame").src=document.getElementById("testFrame").src
},
10000
)
This works by replacing the current document body with an iframe pointing to the window's current location.
Then a call to setInterval is made, that makes the page reload on a timer.
This works well as a bookmark. setInterval's complementary function can be called by bookmark too: javascript:clearTimer(reloadTimer)
Notes:
Some sites detect they are being accessed via iframe and attempt to prevent access (Stack sites for instance!)
Browsers strip the prefix javascript:
when pasting into the address bar so it has to be entered manually. However javascript:
is not stripped if entered via bookmark.
i haven't managed it yet
– jon Jun 13 '12 at 13:22location.reload()
and the page reloads, as far as Chrome is concerned it's basically like loading a new page and the context is all new (the things you typed previously are lost). So you need to persist your code somehow and have the page be the same, which is why the iframe solution of the answer. – ShreevatsaR Mar 5 '16 at 18:05