与安卓交互

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();
}
posted @ 2018-10-20 11:12  码路上的奋斗  阅读(116)  评论(0编辑  收藏  举报