0

I am having a bit of trouble figuring out how I am able to change the URL without redirecting the page. For example, soundcloud.com will not reload the page when you select a new song but the url changes to "soundcloud.com/AUTHOR/NAME". I would really like to know how this is possible, how they have done it.

So far I know that with javascript you are able to rewrite only the values after # in a URL. With .htaccess rewrite rules, I am not sure you can specify that the page shouldn't reload.

Can anyone guide me on the path to figuring out where to start? Thank you very much!

JDW
  • 69
  • 1
  • 10

1 Answers1

0

Take a look at pushState: https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history

Suppose mozilla.org/foo.html executes the following JavaScript: var stateObj = { foo: "bar" }; history.pushState(stateObj, "page 2", "bar.html");

This will cause the URL bar to display mozilla.org/bar.html, but won't cause the browser to load bar.html or even check that bar.html exists.

This only works with HTML5 browsers.

More discussion: Modify the URL without reloading the page

Community
  • 1
  • 1
Oneberg
  • 11
  • 1
  • 1
  • 4