如何soundcloud保持音乐播放航行时呢?音乐播放、soundcloud

2023-09-10 13:18:29 作者:☆_End丶莫弃

我不知道如何 soundcloud 可以在页面之间导航时无缝播放音乐。这可能是因为他们使用Ajax的Cuz顶栏似乎不导航时重新加载,但我看到URL的变化。有没有办法使用Ajax来加载内容和设置URL到另外一个?

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?

推荐答案

HTML5引入了一个新的API,名为HTML5历史API。你可以阅读在这里使用它 - http://diveintohtml5.info/history.html

HTML5 has introduced a new API, called HTML5 History API. You can read about using it here – http://diveintohtml5.info/history.html

该API允许您更新浏览器地址栏的JavaScript,这样你就可以根据URL改变页面的内容。使用Ajax并没有真正都与用户界面的变化,你可以检查在Chrome的开发工具,网络选项卡来查看请求与XHR发出。

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.