0

I have a requirement to edit the query string value in browser's address bar. example: Suppose we have a website www.domainname.com/default.aspx?id=abc.

There are links on page default.aspx named as abc, xyz and pqr. I want if user click on xyz then url should be www.domainname.com/default.aspx?id=xyz. (no server hit), it should be on client end only, no page allowed here. Same for pqr it should be www.domainname.com/default.aspx?id=pqr.

In contrast I want to edit and update query string values via JavaScript in browser's address bar. Is it possible please suggest?

Sid M
  • 4,354
  • 4
  • 30
  • 50
Sarbjit Singh
  • 181
  • 1
  • 2
  • 10
  • 1
    You should probably use the hash string, not the query string, if no server-side code is involved. See [location object](https://developer.mozilla.org/en-US/docs/Web/API/Window.location) – Blazemonger Jan 24 '14 at 14:39
  • your question is still not clear for me. you have links like xyz or like .... href="xyz.aspx" ... ? and if you change urls as you would like, then the page will be "hit" requested server side, otherwise use hash tag – Rami.Q Jan 24 '14 at 14:40
  • HTML5 History API, learn about it. – epascarello Jan 24 '14 at 14:42
  • If you every time want to reload cached CSS files, See this one http://stackoverflow.com/questions/118884/what-is-an-elegant-way-to-force-browsers-to-reload-cached-css-js-files#119056 – Ishan Jain Jan 24 '14 at 14:53
  • possible duplicate of [Assigning to document.location.href without clobbering history](http://stackoverflow.com/questions/864633/assigning-to-document-location-href-without-clobbering-history) – Sean Vieira Jan 24 '14 at 16:15
  • server code is also involved in it. – Sarbjit Singh Jan 24 '14 at 16:34

1 Answers1

3

Modern browsers support HTML History pushState

var stateObj = { foo: "bar" };
history.pushState(stateObj, "page 2", "bar.html");

If you need older browser support, than you are out of luck and have to go the hash route.

epascarello
  • 204,599
  • 20
  • 195
  • 236