How to manipulate the URL with Javascript and JQuery?

前端 未结 4 984
孤城傲影
孤城傲影 2021-01-13 02:29

I want to make a page with a lot of Javascript interactions. However, while a user navigates through the page the URL must change too. So, when the user shares the URL or sa

相关标签:
4条回答
  • 2021-01-13 02:32

    Set this value: window.location.href

      window.location.href = "myapp.com/page2";
    
    0 讨论(0)
  • 2021-01-13 02:37

    The only part of the url (or location) that you can change without reloading the page, is the hash. That is the part behind the #. Many ajax enhanced applications make use of this, including Twitter. You can change this hash on the go, and interpret the hash tag on page load to initialize the page to the correct state.

    0 讨论(0)
  • 2021-01-13 02:43

    pushState, as seen on github

    0 讨论(0)
  • 2021-01-13 02:46

    Answered by this SO question: Change the URL in the browser without loading the new page using JavaScript

    0 讨论(0)
提交回复
热议问题