Possible to rewrite url clientside with javascript without reloading page

前端 未结 4 527
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-31 06:16

Is it possible to rewrite the URL in the URL-field on the client\'s browser?

So when a person clicks on a link on my page something ajax happens (eg a tab shows up)

4条回答
  •  太阳男子
    2020-12-31 07:09

    When everyone else answered this question, they were right, it wasn't possible to change the URL in javascript. With HTML5 and modern browsers, it now is using the HTML5 History API

    diveintohtml5.info article about it. Here is another good blog post explaining the feature.

    Check caniuse.com for browser compatability.

    There are libraries such as History.js which wrap the API and pollyfill using hashbangs for old browsers.

提交回复
热议问题