JS判断当前手机类型

来源:互联网 发布:淘宝主图视频要钱吗 编辑:程序博客网 时间:2024/05/16 10:08

<script language="javascript">

window.onload = 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>

0 0