0

In facebook, whenever you navigate to a different URL (in some situations), the URL changes but there is no feeling sensed as going to a different page.

For example: when we view pictures in facebook, and when we move to the next image the URL changes in the address bar

FROM >facebook.com/foo?bar=foobar&xxxx=

TO > >>facebook.com/foo?bar=boobar&xxxx=

and this is not hashed change also like

FROM >facebook.com/xxxxx#xxx=xxxx

TO > >>facebook.com/xxxxx#xxx=yyyy

How is this possible seamlessly. I mean how is that only a container is modified on URL change. URL change is supposed to navigate to a different page which can contain cached information from previous page and THIS navigation by URL change can be seen obviously by browser's screen going blank for a moment.

If using an iFrame, how to implement this ?

Boopathi Rajaa
  • 4,659
  • 2
  • 31
  • 53

4 Answers4

1

I use somehting similar to this

try {
  var stateObj = { foo: "bar" };
  history.pushState(stateObj, "page", href);
  loadPage(href);
}
catch(e) {
  window.location.hash = "#!/"+href;
}

If it supports the HTML5 pushState them change URL, but if it doesn't then the fall back is the window hash.

Elliot Lings
  • 1,096
  • 1
  • 9
  • 16
0

There's a jQuery plugin called "address" that will watch for changes and call the function you give. I think it's just checking the URL every 100ms or so.

Michael Lorton
  • 43,060
  • 26
  • 103
  • 144
0

wow. I just asked it few minutes ago ... use search next time ;)

Dynamic favicon when I'm proccessing ajax data

Modify the URL without reloading the page

Community
  • 1
  • 1
genesis
  • 50,477
  • 20
  • 96
  • 125
0

They issue an AJAX request for the data necessary to fulfil the "navigation", then tell the browser to "go to #xxx=yyy". Since such an anchor doesn't exist, the browser doesn't actually scroll down. However, it does record a new history entry, and also updates the URL so that if someone copy-pastes that URL, they will view the same object that the user is seeing, rather than just the original page.

Yuliy
  • 17,381
  • 6
  • 41
  • 47