Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
182
rated 0 times [  185] [ 3]  / answers: 1 / hits: 83853  / 12 Years ago, tue, may 22, 2012, 12:00:00

I have a URL with a long query string attached to it.
After the page loads, I do not require the query string. So I want to remove the query string from the address bar without a page reload.



I tried parent.location.hash = ''; and window.location.href = '/#'



They did not make a difference.


More From » html

 Answers
20

You can't do that without reloading the page, imagine if you could put whatever you wanted in the browser address bar? Security fun :)



Although you can now do it in HTML5 (which will only work on browsers supporting it) using the new history API, but realistically, your scenario best warrants a rewrite instead of including that (seems sledgehammer to crack a nut).



As you said you don't need the query string after the page loads, you should really post back, then redirected to another URL after you've finished your processing.


[#85425] Monday, May 21, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
vaughns

Total Points: 20
Total Questions: 112
Total Answers: 112

Location: Falkland Islands
Member since Mon, Jul 13, 2020
4 Years ago
;