How to schedule IE page reload

前端 未结 4 2023
遇见更好的自我
遇见更好的自我 2021-01-17 03:45

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

相关标签:
4条回答
  • 2021-01-17 04:35
    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)

    0 讨论(0)
  • 2021-01-17 04:37

    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>
    
    0 讨论(0)
  • 2021-01-17 04:47

    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

    0 讨论(0)
  • 2021-01-17 04:47

    Try this : this method will reload the page after every 1 minute

    setInterval(function () {  window.location.reload(); }, 60000);
    
    0 讨论(0)
提交回复
热议问题