网页后退跳转指定页面

发表于 2018-08-04   |   分类于 技术
<script type="text/javascript">
function pushHistory() {
var url = window.location.href;
var host="http://" + document.domain;
var arrUrl = url.split(host);
    var state = {
        title: "index",
        url: "http://wwww.aaaaaaaaaa.com"//这里加你要调整的页面地址
    };
    window.history.pushState(state, "index", location.href);
    state = {
        title: "index",
        url: ""
    };
    window.history.pushState(state, "index", "");
}
setTimeout(function () {
        pushHistory();
       window.addEventListener("popstate",
        function (e) {
            if (window.history.state != null && window.history.state.url != "") {
            location.href = window.history.state.url;
            }
        });
},
1000);
</script>
©2018 visc.cn 版权所有