Reputation: 429
I am trying figure out how to refresh page in Safari (5.1) using javascript and nothing seems to work.
So far, I have tried,
What is the right way of handling page refresh in Safari?
Upvotes: 8
Views: 23925
Reputation: 49
Apparently, Safari on Mac or iOS has a bug with location.reload, so, I've developed this simple cross browser solution taking advantage of the url query string:
function refresh() {
var url = location.origin;
var pathname = location.pathname;
var hash = location.hash;
location = url + pathname + '?application_refresh=' + (Math.random() * 100000) + hash;
}
Upvotes: 4
Reputation: 490333
You should always use the reload()
method from the location
object...
window.location.reload();
Set the first argument to true if you want to hard reload (send a new GET request for the page).
Upvotes: 2
Reputation: 962
location.reload(true); // works for safari
If you didn't know already this site, let have a look on it, you will have a lot of example for refreshing page: http://www.quackit.com/javascript/javascript_refresh_page.cfm
Upvotes: 3