Js first use and IOS interact with Andrews, thereby recording, to facilitate subsequent record.
Is connected to or interact through a route between the front page and the page is the front end of the primary interaction by the method. That is, js can call native methods, Android and IOS called in a different way.
So before calling, we must first determine whether the current system is Android or IOS different interactions.
Reference Code:
function callAndroidIOS(arg) { var u = navigator.userAgent, app = navigator.appVersion; var data = null; var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器 var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端 if(isAndroid) { if(window.android) { if(arg == 'register') { register.toRegister(); } else { forgetPass.toForgetPass(); } } } else if(isiOS) { if(window.webkit) { //调用IOS的jumpjumpNext()方法 if(arg == 'register') { window.webkit.messageHandlers.toIOSRegister.postMessage('123'); } else { window.webkit.messageHandlers.toIOSForgetPass.postMessage('123'); } } } };