常规浏览器
window.opener = null;
window.open("about:blank", "_top").close()
关闭微信内置浏览器
if (navigator.userAgent.toLowerCase().match(/MicroMessenger/i) ) {
WeixinJSBridge.invoke('closeWindow',{},function(res){ });
}
微信内置浏览器可能是window.open打开新的页面,为了防止进入历史记录中
pushHistory();
function pushHistory() {
var state = {
title: "title",
url: "#"
};
window.history.pushState(state, "title", "#");
};
window.addEventListener("popstate", function(e) {
WeixinJSBridge.invoke('closeWindow',{},function(res){ });
}, false);
网友评论