goBack: function() { // 回退到APP
var u = navigator.userAgent;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
if(isAndroid) {
window.WebContrl.finish();
}else {
window.webkit.messageHandlers.finish.postMessage('调用了IOS方法');
}
},toApp:function(){ //h5页面,监听手机物理返回键
var _this = this
history.pushState(null,null,location.href);
window.addEventListener('popstate',function(event){
history.pushState(null,null,location.href);
_this.goBack(); //H5自己定义的方法
});
}
版权声明:本文为Hzq88888原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。