h5页面判断移动端系统为Android或IOS
最近遇到了一个需求,即所谓的 app+web 混合开发,需要将 h5 内嵌到 APP 中,这个时候因为要对 Android 和 IOS 有不同的处理逻辑,所以我们就需要判断一下,移动端的系统到时是哪一种。下面我们就提供一下判断型号的方法,代码如下:
function detect(){
let equipmentType = "";
let agent = navigator.userAgent.toLowerCase();
let android = agent.indexOf("android");
let iphone = agent.indexOf("iphone");
let ipad = agent.indexOf("ipad");
if(android != -1){
equipmentType = "android";
}
if(iphone != -1 || ipad != -1){
equipmentType = "ios";
}
return equipmentType;
}
在上面的方法中,返回值为 android 则为 Android 系统,返回值为 ios 则为 IOS 系统。判断完型号,就可以执行对应操作了。
if(detect()==='android'){
//对Android系统的移动端页面做点什么
}else if(detect()==='ios'){
//对IOS系统的移动端页面做点什么
}
h5页面判断移动端系统为Android或IOS的更多相关文章
- vue打包app嵌入h5,区分app进入和android,ios显示不同的下载链接
vue打包app嵌入h5,区分app进入和android,ios显示不同的下载链接 需求:自己app打开的登录页面不显示app下载链接.其他地方打开判断android手机的跳转到android下载页链 ...
- 小程序内嵌H5页面判断微信及小程序环境
判断微信及小程序环境 1.H5页面引入jweixin-1.3.2.js 2. var ua = window.navigator.userAgent.toLowerCase(); if(ua.matc ...
- js,h5页面判断客户端是ios还是安卓
$(function(){ var u = navigator.userAgent, app = navigator.appVersion; var isAndroid = u.indexOf('An ...
- h5页面判断微信端用浏览器打开代码
<div class="weixin-tip"> <p> <img src="img/live_weixin.png" alt=& ...
- JavaScript判断当前手机是Android还是iOS系统
$(function () { var u = navigator.userAgent, app = navigator.appVersion; var isAndroid = u.indexOf(' ...
- PHP 判断客户端请求是 Android 还是 IOS
<?php if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone')||strpos($_SERVER['HTTP_USER_AGENT'], 'iPad ...
- js判断手机系统(Android或IOS),跳转相应下载地址
<script type="text/javascript"> $(document).ready(function(e) { var u = navigator.us ...
- navigator 判断移动端是Android还是iOS
let u = navigator.userAgent; let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > - ...
- js判断手机系统是android还是ios?
var u = navigator.userAgent; //识别各种浏览器 var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Ad ...
随机推荐
- rke安装k8s cluster配置
rke安装k8s cluster配置 最简配置 cluster.yml nodes: - address: 192.168.0.103 user: lishikai role: [controlpla ...
- php设计模式之责任链模式实现举报功能实例代码
html <html> <head> <meta charset="UTF-8"> <title>责任链模式</title&g ...
- 解决报错Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: TLS handshaketimeout
报错: [root@localhost /]# sudo docker pull ubuntuError response from daemon: Get https://registry-1.do ...
- CMD命令行实现复制一张图片1000份:
CMD命令行实现复制一张图片1000份: 进入CMD命令行后,进入图片所在目录,执行以下命令: FOR /L %i IN (,,) DO COPY .jpg %i.jpg 模板图片名字为1.jpg,执 ...
- 关于使用ssm与spring时,配置tomcat 虚拟目录( doBase )中的一些坑
一.使用SSM需要 配置虚拟目录时 tomcat的配置 在tomcat server.xml的<HOST></HOST>中加入以下内容 在配置完成之后,当我们访问URL 为 ...
- 09day 命令提示符优化及yum优化
export PS1='\[\e[32;1m\][\u@\h \W]\$ \[\e[0m\]' 设置颜色 内容 结束 export PS1='\[\e[30;1m\][\u@\h \W]\$ \[\e ...
- C#类和对象的理解
C#是面向对象的开发语言 类:抽象的(模板)不占用内存空间 对象:具体的(真实存在事物)占用内存空间
- 【Python】如何处理Excel中的数据
我们平时在做自动化测试的时候,可能会涉及到从表格中去读取或者存储数据,我们除了可以使用openpyxl来操作excel,当然也可以利用pandas来完成,这篇随笔只是我在学习过程中的简单记录,其他的功 ...
- STA之OCV
Timing sign-off Corner = library PVT +RC Corner + OCV 针对每个工艺结点,foundry都会给出一张类似的timing sign-off表格,定义了 ...
- Java日期时间API系列13-----Jdk8中java.time包中的新的日期时间API类,时间类转换,Date转LocalDateTime,LocalDateTime转Date等
从前面的系列博客中可以看出Jdk8中java.time包中的新的日期时间API类设计的很好,但Date由于使用仍非常广泛,这就涉及到Date转LocalDateTime,LocalDateTime转D ...