
正文
js-控制浏览器和移动端的后退按钮 . popstate
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
//控制浏览器和移动端的后退按钮
if (window.history && window.history.pushState) {
$(window).on('popstate', function () {
var block1 = $('#pop').css('display');
if (block1 == 'block') {
window.location.href = attrHref;
}
var hashLocation = location.hash;
var hashSplit = hashLocation.split("#!/");
var hashName = hashSplit[1];
if (hashName !== '') {
var hash = window.location.hash;
if (hash === '') {
popBox.style.display = 'none'
popSub.style.display = 'block'
// $("#pop").fadeIn(500);
// window.history.pushState('forward', null, 'http://xxl.njxsmfyh.com/0502/ht/');
// window.location.reload();
}
}
});
history.pushState(null, null, location.href);
window.addEventListener('popstate', function (event) {
history.pushState(null, null, location.href);
});
}







