判断类型:
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) { blin.CallAndroid(xxxx, yyyyy); } if (isiOS) { var jsonString ="{"XXXXXXXXXX":"+xxxxxxxx+","YYYYYYYYY":""+yyyyyyyy+""}"; window.webkit.messageHandlers.AppModel.postMessage({body:jsonString}); }