H5页面调用原生方法返回
程序员文章站
2024-02-29 19:06:46
...
var userAgent = navigator.userAgent.toLowerCase();
// 调用原生方法返回
function back() {
if (equipment('iphone')) {
naviBack({ isRefresh: '0', callBack: 'isRefresh()' });
} else if (equipment('ipad')) {
naviBack({ isRefresh: '0', callBack: 'isRefresh()' });
} else if(equipment('android')) {
JsBridge.call('JSBridge', 'naviBack', { isRefresh: false, callBack: 'isRefresh()' }, (res) => {});
} else {
window.history.go(-1);
}
}
function equipment(val){
var res = false;
var userAgent = navigator.userAgent.toLowerCase();
console.log(userAgent);
if(userAgent.indexOf(val) > -1) {
res = true;
}
return res;
};
下一篇: Java中锁的实现和内存语义浅析