js移动端判断手机系统

<!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>

posted @ 2017-06-12 20:32  missJun  阅读(3004)  评论(0编辑  收藏  举报