js如何判斷手機機型


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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM