1. 程式人生 > >與安卓互動

與安卓互動

var browser = { versions: function () { var a = navigator.userAgent, b = navigator.appVersion; return { trident: a.indexOf("Trident") > -1, presto: a.indexOf("Presto") > -1, webKit: a.indexOf("AppleWebKit") > -1, gecko: a.indexOf("Gecko") > -1 && a.indexOf("KHTML") == -1, mobile: !!a.match(/AppleWebKit.*Mobile.*/), ios: !!a.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), android: a.indexOf("Android") > -1 || a.indexOf("Linux") > -1, iPhone: a.indexOf("iPhone") > -1, iPad: a.indexOf("iPad") > -1, webApp: a.indexOf("Safari") == -1 } }(), language: (navigator.browserLanguage || navigator.language).toLowerCase() }; if (browser.versions.android) { //Android window.Android.toTakePhoto(); }