基础 - 访问历史

  function funQianJin() {
        window.history.forward();
    }
    function funHouTui() {
        window.history.back();
    }
    function funShuaXin() {
        window.history.go();
    }

 H5

    /*留下历史记录*/
    if (window.history && window.history.pushState) {
        window.history.pushState("event.state","预留,暂时无用","?mark="+"地址栏显示内容");
    }
    /*点击前进或后退自动调用*/
    window.addEventListener("popstate",function(event) {
        console.log(event.state);
    })

  

    /**
     * 解析地址栏
     * encodeURI()  将普通字符串百分化
     * decodeURI()  将百分字符串普通化
     **/
    var sFlxAdd = window.location.search;
    var sMarkEx = sFlxAdd.split("mark=")[1].split("&")[0];
    var sMark = decodeURI(sMarkEx);
    console.log(sMark);

  

  

posted @ 2016-08-26 12:23  WeWeZhang  阅读(151)  评论(0编辑  收藏  举报