网页后退强制跳转页面的js代码

发表于 2018-08-04   |   分类于 技术

网页后退强制跳转页面的js代码

<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: "https://wwww.visc.cn/"//跳转的网址
};
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>
©2020 visc.cn All Rights Reserved
Powered by Typecho & Theme Quark
苏ICP备20028920号-1