目前接到一个项目,需求 用到网页端 调起APP ,但是只有部分浏览器器支持,也只有部分的机型支持。如果更多的兼容 机型代码 如下
var get_appdown_conf=function(conf) {
var openAppUrl = "wbmain://nativejump?pagetype=main";
var appdown = conf['container'];
if(!(appdown instanceof HTMLElement)){
return false;
}
function getWlsour(regExp){
var tempWlsour = "oth";
var ua = navigator.userAgent.toLocaleLowerCase();
for(key in regExp){
if(regExp[key].test(ua)){
tempWlsour = key;
break;
}
}
return tempWlsour;
}
var regExp = {
weixin:/micromessenger\//ig,
momo : /momowebview\//ig,
qq : /mqqbrowser\/|\sqq\//ig,
baidu : /baidu/ig,
uc : /ucbrowser/ig,
xiaomi : /xiaomi\//ig,
firefox : /firefox/ig,
opera : /opr\/|opera/ig,
sogou : /sogoumobilebrowser/ig,
liebao : /liebao/ig,
oppo : /oppobrowser/ig,
360 : /360 aphone browser/ig,
//判断完其他的内容后再判断是否为safari
safari : /version\/([0-9]+\.\d[\.\d]*)\s+mobile\/\w+\s+safari\/([0-9]+\.\d[\.\d]*)/ig,
chrome : /chrome\/([0-9]+\.\d[\.\d]*)+\s+mobile\s+safari\/([0-9]+\.\d[\.\d]*)$|crios/ig
}
var objPara = {
pid:appdown.getAttribute('data-pid'),
wlmode:"sc",
wltype:(conf['wltype'] ? conf['wltype'] : 'bro'),
wlsour:(conf['wlsour'] ? conf['wlsour'] : getWlsour(regExp))
};
var arrPara = [];
for(var k in objPara){
if(objPara[k]){
arrPara.push(k+'=' + objPara[k]);
}
}
var strPara = arrPara.join('&');
openAppUrl += (strPara ? '&' + strPara : '');
var jumpUrl = appdown.getAttribute('data-jumpUrl');
var tongjitag = appdown.getAttribute('tongji_tag');
var conf = {
ios: {
openAppUrl: openAppUrl, //ios打开app的url,
jumpUrl: jumpUrl, //ios下载app的url,奥林匹亚放中间页的url
clickLog: tongjitag + '_' + 'ios'
},
andr: {
openAppUrl: openAppUrl, //android打开app的url,
jumpUrl: jumpUrl, //android下载app的url,奥林匹亚放中间页的url
clickLog: tongjitag + '_' + 'andr' //android点击发送的统计参数
}
};
return conf;
}