I'm wondering how soundcloud can play music seamlessly when navigating between pages. It's possible that they use Ajax cuz the top bar seems not to reload when navigating but i see the URL changes. Is there any way to load content using Ajax and set the URL to another one?
Asked
Active
Viewed 9,837 times
1 Answers
22
HTML5 has introduced a new API, called HTML5 History API. You can read about using it here – http://diveintohtml5.info/history.html
This API lets you update browser address bar with JavaScript, so you can change the contents of the page according to the URL. The use of AJAX doesn't really have to do with UI changes, you could check the networks tab in Chrome's developer tools to see that requests are issued with XHR.

Misha Reyzlin
- 13,736
- 4
- 54
- 63
-
although it's an old post, I am facing an issue with something similar. I can keep the audio playing while refreshing the page, but since I use own my audio player, the duration/event that handles the animation 0:01 - 0:02 - 0:03 ... just stops, I can't keep the data with the position the song was before refreshing. do you have an idea? – Eu Chi Oct 07 '18 at 18:07
-
@EuChi when you say "refreshing the page", do you mean that the page is reloading, meaning that HTML is re-requested? Or do you mean that you update the contents of the page manually? – Misha Reyzlin Oct 08 '18 at 09:51
-
I was asking a way to reload DOM with ajax and keep audio playing, I wasn't able to keep it playing with the duration animation. Now I just put the audio out of refreshed div – Eu Chi Oct 11 '18 at 20:23