2015/06/17

History State API

History State API 的概念就是 push 跟 pop stack
var pushstack = true; // 控制操作是否要記錄 State
function doSomething() {
    if(pushstack) {
        window.history.pushState({ customVal1: 1, customVal2: 2}, "PageTitle", TargetURL);
    }
}

window.onpopstate = function(e) {
    // get e.state value
}

No comments:

Post a Comment