// 通过ua标识判断
var userAgent = navigator.userAgent.toLowerCase();//获取UA信息 if(userAgent.indexOf("ezhouxing") != -1){//判断ua中是否含有和app端约定好的标识ezhouxing alert('包含'); }
今天见到同事的骚操作:
function urlParse (queryStr) { let arr = queryStr.slice(1).split('&'); let map = {}; arr.forEach(item => { let param = item.split('='); map[param[0]] = param[1]; }); return map; } if (urlParse(window.location.search).app === "app") { isApp = true //客户端调用 } else { isApp = false //非客户端调用 }
如有疑问,可留言!