12月21日
微信公众号监听返回按钮问题解决
//首页返回路径$(function(){pushHistory();var bool = false;setTimeout(function(){bool = true;},500);window.addEventListener("popstate", function(e) {if(bool){//手机终端判断var u = navigator.userAgent; var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端 var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端if(isAndroid){//WeixinJSBridge.call('closeWindow');location.href='/';}else{location.href='/';}}}, false);});function pushHistory() {var state = {title: "",url: "/"}; window.history.pushState(state, state.title, state.url); }
如果觉得《微信公众号监听返回按钮问题解决》对你有帮助,请点赞、收藏,并留下你的观点哦!