微信内置浏览器部分Andriod机型不兼容popstate监听事件(和页面交互能解决此问题---禁止返回需求),IOS没问题

 
//防止页面后退
history.pushState(null, null, document.URL);
window.addEventListener('popstate', function () {
  history.pushState(null, null, document.URL);
});

微信开放社区:
https://developers.weixin.qq.com/community/develop/doc/000a2a57968cc0bc9d7aa0b6b5b800?highLine=popstate

 

社区给出解决方案:

try { window.tbs_bridge.nativeExec('network', 'type', 0, null); } catch (e) { console.error(e); }

 实测无效。

 

posted @ 2022-06-30 15:36  Action_swt  阅读(782)  评论(0)    收藏  举报