js判断设备是iOS还是安卓

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" />

<title></title>

<style>div{width: 200px;height: 200px;background: #f06;}</style>

</head>

<body>

<div id="download">点击判断设备是iOS还是安卓</div>

<script src="js/jquery.js"></script>

<script>

var download = {

downloadApp : function(){

var xt = navigator.userAgent;

if(xt.indexOf("OS") > -1){

window.location.href="http://www.baidu.com";

}else{

window.location.href="http://3g.163.com/touch/all?dataversion=A&version=v_standard";

}

}

};

$(function(){

$("#download").click(function(){

download.downloadApp();

});

})

</script>

</body>

</html>

 

posted @ 2017-05-27 11:31  慕小橙  阅读(2282)  评论(0编辑  收藏  举报