在微信浏览器上点击不起作用,而在其他设备均没问题。
解决办法:
在点击事件前面加入这个代码启用点击事件。
// IOS 微信浏览器开启点击事件 $("body>*").bind("click",function(){});
原因是:
IOS微信浏览器的window、document、body并不接受click事件,按钮和链接才接受click事件。
代码中body换为需要点击的标签。
微信浏览器左上角返回按钮的监听
$(function(){
//监听浏览器返回的事件
pushHistory();
window.addEventListener("popstate", function(e) {
//alert('start');
//document.getElementById("start").style.display = "none";
//alert('ok');
window.location.reload();
//WeixinJSBridge.call('closeWindow'); //直接关闭页面,返回到微信聊天界面
}, false);
function pushHistory() {
var state = {
title: "title",
url: "#"
};
window.history.pushState(state, "title", "#");
}
});
这个事件的监听并没有在每个页面都放上,由于规定每个页面点击微信返回都会回到主页面,因此只在主页面上加了一个上述函数。
本是误操作,结果却成功了!
具体原因还是有待商榷!