Skip to content Skip to sidebar Skip to footer

Javascript Page Reload Or Meta Tag Refresh Method?

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 Javas

Solution 1:

You can use

<metahttp-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);

Solution 2:

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

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

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

Solution 3:

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 recommend the javascript version. If not I normally do both so the page redirects as fast as possible.

Solution 4:

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.

Post a Comment for "Javascript Page Reload Or Meta Tag Refresh Method?"