标签:bsp init html getc tle tco eid fun let
方法一: HTML+ 封装好的方法,额外配置,使用指定方法打包才可用
参考地址: http://www.html5plus.org/doc/zh_cn/device.html
方法二:引用插件mobile-detect.js,可以获取
参考地址:http://hgoebl.github.io/mobile-detect.js
下载地址:https://github.com/hgoebl/mobile-detect.js/
方法三:调用app的native方法,jsBrage交互获取json字符串
//app交互 var flag; var jsBridge = (function () { function connectWebViewJavascriptBridge(callback) { if (window.WebViewJavascriptBridge) { callback(WebViewJavascriptBridge); } else { document.addEventListener(‘WebViewJavascriptBridgeReady‘, function () { callback(WebViewJavascriptBridge); }, false) } } connectWebViewJavascriptBridge(function (WebViewJavascriptBridge) { WebViewJavascriptBridge.init(function (message, responseCallback) { }); WebViewJavascriptBridge.registerHandler("contactsList", function(data, responseCallback) { phoneNumbers=(data); }); WebViewJavascriptBridge.registerHandler("contacts", function(data, responseCallback) { var datas=JSON.parse(data); if(currentNum==1){ name1=datas.name; tel1=datas.phone; $("#firstTxtName").val(datas.name); $("#firstTxtTel").val(datas.phone); }else { name2=datas.name; tel2=datas.phone; $("#secondTxtName").val(datas.name); $("#secondTxtTel").val(datas.phone); } }); WebViewJavascriptBridge.callHandler(‘getAppVersion‘, {}, function (response) { callback(response); }); fn && fn(); }) return { init: function (fn) { connectWebViewJavascriptBridge(function (WebViewJavascriptBridge) { WebViewJavascriptBridge.init(function (message, responseCallback) { }); fn && fn(); }) }, copyWechat: function (obj) { WebViewJavascriptBridge.callHandler(‘copyWechat‘, { pageID: obj.pageID }, function (response) { }); }, saveQR: function (obj) { WebViewJavascriptBridge.callHandler(‘saveQR‘, { pageID: obj.pageID }, function (response) { }); }, showAppPage: function (obj) { WebViewJavascriptBridge.callHandler(‘showAppPage‘, { pageID: obj.pageID }, function (response) { }); }, jumpTo: function (obj) { WebViewJavascriptBridge.callHandler(‘jumpTo‘, {}, function (response) { }); }, showWebPage: function (obj) { WebViewJavascriptBridge.callHandler(‘showWebPage‘, { title: obj.title, pageUrl: obj.pageUrl }, function (response) { }); }, getSid: function (callback) { WebViewJavascriptBridge.callHandler(‘getSid‘, {}, function (response) { callback(response); }); }, getContacts: function (callback) { WebViewJavascriptBridge.callHandler(‘getContacts‘, {}, function (response) { callback(response); }); }, getAppVersion: function (callback) { WebViewJavascriptBridge.callHandler(‘getAppVersion‘, {}, function (response) { flag=response; callback(response); }); } } })();
js获取移动端设备信息(IMEM,IMIS,手机型号,系统版本,浏览器信息等)
标签:bsp init html getc tle tco eid fun let
原文地址:https://www.cnblogs.com/dontes/p/9075877.html