Monday, May 20, 2024
91
rated 0 times [  92] [ 1]  / answers: 1 / hits: 23753  / 13 Years ago, tue, july 26, 2011, 12:00:00

I want to change URL without without reloading the page. The possible solution I found is




window.history.pushState('page2', 'Title', '/page2.php');




but some browser like Firefox 3.5, IE6+ does not support this, so for them solution is




var uri = window.location.href;




but the issue is how to discover if a browser supports history.pushstate or not?



Is TRY CATCH is the possible solution or any thing else.


More From » cross-browser

 Answers
15
if (history.pushState) {
// supported.
}


Quickest test is to run this in the browser console to see if it's supported:



if (history.pushState) { alert('supported'); }


Also notice that in FF typeof(history.pushState) returns function, while in IE it returns undefined


[#91010] Saturday, July 23, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jazminuniquer

Total Points: 63
Total Questions: 121
Total Answers: 96

Location: Cambodia
Member since Thu, May 21, 2020
4 Years ago
;