24

Is it possible to change the URL in the browser address bar directly with jQuery without refreshing the page or redirecting to the changed url?

Or is this not possible due to security issues?

For example, I have a list which is jquery.ajax driven so no post backs/screen refreshes. The list has a paging element. So for the first page the url in the browser address bar is:

http://company/list.php?page=1

If I click on page 2 from the paging section of the list, it displays the list based on page 2, but as this is happening ajax style without refreshing/posting back, the browser url remains at

http://company/list.php?page=1

I want to be able to change it to

http://company/list.php?page=2

without posting back/redirecting to the new url

Is this not possible?

oshirowanen
  • 15,297
  • 82
  • 198
  • 350

2 Answers2

19

This can only be done in more modern browsers (Chrome, Safari, FF4+, and IE10pp3+)

See this question: Updating address bar with new URL without hash or reloading the page for information on how to do it.

Community
  • 1
  • 1
Tim
  • 7,660
  • 3
  • 30
  • 33
6

Maybe with some modification you could use Fragment Identifier aka Hash (# sign in the Url) to change (part of) Url without page change.

Normally this is used to automatically navigate user to certain chapter in the page or initialize control to certain state. For example automatically select correct tab in the tab control. Ben Alman has an example about that (using jQuery BBQ).

Tx3
  • 6,796
  • 4
  • 37
  • 52