History replacestate/pushstate

Source: Internet
Author: User

HTML5 history has added two properties, namely Replacestate () and Pushstate (), and does not refresh the URL of the page change page.

Replacestate () Can change URLs without a page refresh

Usage: History. Replacestate("Data","title of page","changed url")

<body><input type= "button" value= "buttons" id= "btn" ></body><script>$ (' #btn '). Click (function () { History.replacestate (null, "title", "aa.html?name=12345"), History.replacestate (null, "title", "bb.html?name=67890" );}) </script>

PS: the title of some pages can not be changed after testing

Pushstate () is a record of inserting a URL into the browser history, and then inserting it at the very top of the record (array), the same way replacestate can make the page not refresh the URL change, the difference is the URL can be returned to the previous record through the browser, The advantage is that you can return to the pre-render record by using the browser Back button after the AJAX partial rendering page

Usage: History. Pushstate("Data","title of page","changed url")

<body><input type= "button" value= "buttons" id= "btn" ></body><script>$ (' #btn '). Click (function () { History.pushstate (null, "title", "aa.html?name=12345"), History.pushstate (null, "title", "bb.html?name=67890");}) </script>

  

History replacestate/pushstate

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.