Friday, February 27, 2015

Different ways to refresh or reload page using jQuery

You can also use jQuery to refresh/reload the page automatically. See below jQuery code. 
1function ReloadPage() {
2   location.reload();
3};
4 
5$(document).ready(function() {
6  setTimeout("ReloadPage()", 10000); .
7});
location.reload() will reload the page again. The advantage of location.reload() is that it works with all the major browsers.

If you want to reload the page on click of button, then you can call location.reload() on button click event. See below jQuery code. 
1$(document).ready(function() {
2     $('#btnReload').click(function() {
3             location.reload();
4       });
5});

No comments:

Post a Comment