js移动端判断手机系统

╄→гoц情女王★ 提交于 2020-01-31 02:48:52

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>判断手机型号</title>
<style type="text/css">
body{
font-size:200px;
}
</style>
</head>
<body>
<div class="ios"id="ios" >
判断
</div>

</body>
<script src="jquery-1.7.2.min.js" type="text/javascript" charset="utf-8"></script>
<script language="javascript">

window.onload = function () {
$('.ios').on('click',function(){


alert("1");
var u = navigator.userAgent;
if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) {//安卓手机
alert("安卓手机");
// window.location.href = "mobile/index.html";
} else if (u.indexOf('iPhone') > -1) {//苹果手机
// window.location.href = "mobile/index.html";
alert("苹果手机");
} else if (u.indexOf('Windows Phone') > -1) {//winphone手机
alert("winphone手机");
// window.location.href = "mobile/index.html";
}
})
}
</script>
</html>

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!