0

I want to change the URL (QueryString Data) after the Page gets Displayed. How can i do it ?

Emil H
  • 39,840
  • 10
  • 78
  • 97
  • Are you looking for a way to add queries to your URL? Like "www.example.com?data=value" – peirix Jul 03 '09 at 06:22
  • Actually i dont want my Page to get Refresh. Is it possible ? –  Jul 03 '09 at 06:23
  • I don't think what you're trying to do can be done. Furthermore, I don't think you understand what you're trying to do. – Chris Jul 03 '09 at 06:23
  • Actually my URL is like www.example.com?id=5, I want it to be www.example.com after it gets Loaded. –  Jul 03 '09 at 06:25
  • Sounds like you need to rethink your application design. Why not have it do the work at id=5, then save some kind of context cookie and then redirect to example.com and have example.com display its data based on the context cookie? – Nathan Ridley Jul 03 '09 at 06:31
  • 1
    http://stackoverflow.com/questions/824349/modify-the-url-without-reloading-the-page – Mike Cooper Jul 03 '09 at 06:31

2 Answers2

7

You can't. The only part of the location that can be changed without the browser requesting a new URL from the server is the hash (since that is local to the current document).

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
-2

The javascript object window.location have property href. So you can change it in JavaScript code in such way:

location.href = 'http://stackoverflow.com/'
Alex Pavlov
  • 630
  • 5
  • 14