JS判斷手機系統

<script language="javascript">javascript

window.onload = function () {html

alert("1");java

//alert(navigator.userAgent.indexOf());spa

var u = navigator.userAgent;htm

if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) {//安卓手機ip

alert("安卓手機");it

// window.location.href = "mobile/index.html";io

} else if (u.indexOf('iPhone') > -1) {//蘋果手機function

// window.location.href = "mobile/index.html";mobile

alert("蘋果手機");

} else if (u.indexOf('Windows Phone') > -1) {//winphone手機

alert("winphone手機");

// window.location.href = "mobile/index.html";

}

}

</script>

相關文章
相關標籤/搜索