监听微信底栏返回事件,然后关闭窗口?
ios 微信监听popstate,然后关闭微信窗口,确实也会关闭,但是在关闭之前会返回一下上一个页面才关闭,请问如何解决?
pushHistory()
window.addEventListener('popstate', function (e) {
var ua = navigator.userAgent.toLowerCase()
if (ua.indexOf('micromessenger') > -1) {
// eslint-disable-next-line no-undef
WeixinJSBridge.call('closeWindow')
} else if (ua.indexOf('alipay') > -1) {
// eslint-disable-next-line no-undef
AlipayJSBridge.call('closeWebview')
} else {
window.close()
}
}, false)
function pushHistory () {
var state = {
title: 'title',
url: '#'
}
window.history.pushState(state, 'title', '#')
}