最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery - Javascript page reload or Meta Tag refresh method? - Stack Overflow

programmeradmin0浏览0评论

I looking to add a script to my aspx page that will refresh/reload the page every 15secs. There is dynamic data on my page that is sourced from Oracle. I found that I can use Javascript "reload" or the Meta Tag method, which is the best method to use to refresh a page with dynamic data?

Thanks alot!

I looking to add a script to my aspx page that will refresh/reload the page every 15secs. There is dynamic data on my page that is sourced from Oracle. I found that I can use Javascript "reload" or the Meta Tag method, which is the best method to use to refresh a page with dynamic data?

Thanks alot!

Share Improve this question asked Jan 2, 2013 at 16:36 charliecharlie 3232 gold badges7 silver badges16 bronze badges 1
  • 2 both methods will refresh the page, meta will not use javascript at all but sometimes browser could have meta redirection disabled (so I think there's not an objective best option) – Fabrizio Calderan Commented Jan 2, 2013 at 16:43
Add a ment  | 

4 Answers 4

Reset to default 3

You can use

<meta http-equiv="refresh" content="15"> 

but it has also drawbacks. For example if the user load the next page before 15 sec. You may get some anexpected browser reloads

using javascript you may do something like

window.setTimeout(function(){window.location.href=window.location.href},15000);

You could use setInterval in bination with an $ajax request:

setInterval(function(){
   $.ajax({
  url: someUrl,

  context: $('#myDiv')
}).success(function(data) { 
  $(this).html(data);
});
},15000);

I believe the meta tag way is only used on page load to reload the page. This method is good because it doesn't use any javascript, so if there is a problem then the page will still reload. However this tag is seen as spam to spiders. If you are wanting to redirect after page load. I'd remend the javascript version. If not I normally do both so the page redirects as fast as possible.

There are newer ways to deal with data refreshing that are more robust. You might consider looking into web sockets.

These are low latency live connections between the web browser and the server that allow messages (data) to be sent back and forth.

发布评论

评论列表(0)

  1. 暂无评论