$(function(){ pushHistory(); window.addEventListener("popstate", function(e) { //alert("我监听到了浏览器的返回按钮事件啦");//根据自己的需求实现自己的功能 //alert('guanbi'); WeixinJSBridge.call('closeWindow'); if(typeof(WeixinJSBridge)!="undefined"){ WeixinJSBridge.call('closeWindow'); }else{ if (navigator.userAgent.indexOf("MSIE") > 0) { if (navigator.userAgent.indexOf("MSIE 6.0") > 0) { window.opener = null; window.close(); } else{ window.open('', '_top'); window.top.close(); } } else if (navigator.userAgent.indexOf("Firefox") > 0) { window.location.href = 'about:blank '; //window.history.go(-2); } else{ window.opener = null; window.open('', '_self', ''); window.close(); } } }, false); window.onbeforeunload = function() { return; } functionpushHistory() { var state ={ title: "title", url: ""}; window.history.pushState(state, "title", ""); } });
js监听返回事件,返回直接关闭窗口事件(微信网页返回关闭)
免责声明:文章转载自《js监听返回事件,返回直接关闭窗口事件(微信网页返回关闭)》仅用于学习参考。如对内容有疑问,请及时联系本站处理。
上篇Android使用OpenGL ES2.0显示YUV,您的手机上的数据要解决两个方面的坐标Win7/8双系统共用蓝牙鼠标下篇
宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=