- 检测是否在客户端App内
复制代码
1
2
3
4
5
6
7
8
9
10
11
12function is_app() { var userAgent = navigator.userAgent.toLowerCase();//获取UA信息 if (userAgent.indexOf("xxxxxx") != -1) { //判断ua中是否含有和app端约定好的标识xxxxxx return true // 在app内 } else { return false // 不在 app 内 } }
- 检测是否在Android内
复制代码
1
2
3
4
5function isAndroid() { const userAgent = navigator.userAgent; return userAgent.indexOf('Android') > 0; },
- 检测是否在IOS内
复制代码
1
2
3
4
5function isAndroid() { const userAgent = navigator.userAgent; return /(iPhone|iPad|iPod)/i.test(userAgent); },
最后
以上就是飞快星星最近收集整理的关于H5 环境检测的全部内容,更多相关H5内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复