问题
Is there a mechanism i can use to force page reload every 'n' minutes? I can't modify the page code itself, "refresh" request should be issued from outside of the page itself
回答1:
var timedRefresh = setTimeout(function(){location.reload(true)},1*60000)
That will refresh the page every minute. If you make it into a script for greasemonkey it will continually be injected into the page and keep executing every minute + load time.
ANother way is to, as suggested, put the page in an iframe. e.g.
if (self == top){
document.body.innerHTML = '<iframe id="meh" src="' + location.href + '" width="100%" height="100%">';
var t = setInterval("document.getElementById('meh').src = location.href", 1000);
}
That has only been tested in Chrome however, and innerHTML may pose some problems with IE. (not sure though)
回答2:
You could try putting the site within an iframe and refreshing that via Javascript at set intervals.
For a more simple solution, depending on your actual needs, I have used the following site for something similar:
http://www.lazywebtools.co.uk/cycler.html
回答3:
The wollowing works well. Replace "cnn.com" with the page you need to reload and "10" with the interval in seconds
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 11 February 2007), see www.w3.org" />
<meta http-equiv="PRAGMA" content="NO-CACHE" />
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<title>Some title</title>
<meta http-equiv="REFRESH" content="10" />
</head>
<body>
<iframe src="http://www.cnn.com" frameborder="0" scrolling="no" style=
"width:100%; height:100%;"></iframe>
</body>
</html>
回答4:
Try this : this method will reload the page after every 1 minute
setInterval(function () { window.location.reload(); }, 60000);
来源:https://stackoverflow.com/questions/6864931/how-to-schedule-ie-page-reload