开发者

if <meta> is deprecated for auto refreshing, what should i use?

I've been using <meta http-equiv="refresh" content="5"> for a little while to auto update my pages, and then I found that clicking refresh before the 5 seconds is up causes the auto update not to work, at least in IE8.

So I decided to research the <meta> tag and found, according to wikipedia: " Auto refreshing开发者_StackOverflow中文版 via a META element has been deprecated for more than ten years [5] and recognized as problematic before that ".

So, what SHOULD I be using to auto update my pages? (I am guessing it will be a javy scripty kinda thingy.)

Thanks bunches in advance!!!!


use

<script>
 setTimeout("window.location.reload(true);",5000);
</script>

or

<input type="button" value="Reload Page" onClick="window.location.reload()">


Yeah, you can do it easily with javascript.

Something like that:

function timedRefresh(timeoutPeriod) {
setTimeout("location.reload(true);",timeoutPeriod);
}

I don't know what you really want to do, but refreshing the entire page might be overkill.

Consider using JQuery/AJAX to refresh only a part of your page.


You could do something like this:

function timedRefresh() {
    setTimeout("location.reload(true);",5000);
}

This will put a timeout on your page to trigger a refresh every 5 seconds.


Everyone has gone the javascript "alternative", but I would like to also stand by and mention that if you find yourself needing to refresh the whole page, it may be time to decide if AJAX is worth it for your site.

Depending on the content(s) being refreshed, the "new standard" is to use AJAX behind the scenes to poll/refresh content, and keeps browsing history in tact.


<body onLoad="setTimeout('window.location = window.location;',5000);">
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜