HTML5 History object, JavaScript modifies the address bar without refreshing the page (ii)

Source: Internet
Author: User

First, the example illustrates:

$ (' #btnOne '). Click (function () {    varStateObject = {Id:1 }; vartitle = "Local Home"; varNewurl = '/index.html '; //modify addresses in the address bar    /** instructions for use, cached address in pushstate, must be an address in the current domain */history.pushstate (stateobject, title, Newurl);}); $(' #btnTwo '). Click (function () {    //Get Operation HistoryConsole.info (history.length);}); Window.addeventlistener (' Popstate ',function(event) {Console.info (event);    Console.info (event.state); /** event.state.id get instructions, first open page without ID, will throw an exception */Console.info (event.state.id);});

Test Result: IE10 and above browser support, GOOGLE,FF support

HTML5 History One: http://www.cnblogs.com/tianma3798/p/5584541.html

HTML5 History object, JavaScript modifies the address bar without refreshing the page (ii)

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.