编程网

window.onpopstate触发无效的解决方案

在微信浏览器中加入window.onpopstate监听事件,但是一直无法触发,后来查找网上资料,找到一个解决方案 。

window.onpopstate = function(event) { 
console.log(sfa);
};
//加入以下俩行代码,才能触发
window.history.pushState('forward', null, '#');
window.history.forward(1);


热门内容