检测微信返回按钮事件
function isWeiXin() { var ua = window.navigator.userAgent.toLowerCase(); if (ua.match(/MicroMessenger/i) == 'micromessenger') { pushHistory(); var bool = false; setTimeout(function() { bool = true; }, 1500); window.addEventListener("popstate", function(e) { if (bool) { //需要处理的操作 } pushHistory(); }, false); }; } function pushHistory() { var state = { title: "title", url: "#" }; window.history.pushState(state, "title", "#"); } isWeiXin()