开发者

Refresh HTML Page in Browser Automatically on Timer - Every 15 Min

开发者 https://www.devze.com 2023-03-31 05:00 出处:网络
Is it possible to automatically refresh a website on a timer, like every 15 minutes?Basically, we will be making updates to a website and we want it to automatically refresh so it will show up on a bi

Is it possible to automatically refresh a website on a timer, like every 15 minutes? Basically, we will be making updates to a website and we want it to automatically refresh so it will show up on a big monitor we have which is controlled from a different computer.

So instead of going to that other computer to click refresh when changes are mad开发者_JAVA百科e, it would just automatically refresh so we can keep it up there.

Thanks!


Place this inside <head> to refresh page after 900 seconds:

<meta http-equiv="refresh" content="900"> <!-- Refresh every 15 minutes -->

For what it's worth, the w3c has officially deprecated this feature, but browsers continue to support this feature. For your purposes, this is an ideal solution. It's just not a recommended solution for "public" (www)-facing web sites any more.


window.setTimeout(function(){
//refresh the page after 900,000 miliseconds (15 minutes)


//reload the page (javascript has many ways of doing this)
location.reload();
},900000);

That should help.


You dont even need js to do this! Look at the refresh meta tag: http://webdesign.about.com/od/metataglibraries/a/aa080300a.htm You can use this to refresh the page on any interval.


Although the refresh meta tag is the simpler solution to update information on a webpage it is also a pretty old and dated solution.

Imagine for example that Google maps would need to refresh the whole page when you pan the map view. There is where ajax comes in, you can find a lot information about it online like this for example.

I don't know specifically what was your intention but just wanted to give this background information, if just a refresh is really what you need then the answers from box86rowh and ckittel is all you need.


Pass the url in the querystring, and then just load it in a frame

source: javascriptkit.com

<script>
<!--
should range from 0 to 59
var limit="0:30"
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()",200)
    }
}

 window.onload = beginrefresh
 //-->
</script>
</head>
<body>
<iframe src="" id="refreshResults" frameborder="0" width="1800" height="1800"></iframe>

<script>

    var http = new XMLHttpRequest();

    $(function(){
        $("#refreshResults").attr('src','<%=Request.Querystring("w")%>');
    });

</script>
0

精彩评论

暂无评论...
验证码 换一张
取 消