用javascript判断当前是安卓平台还是ios平台

通常判断运行环境都是通过navigator.userAgent

if (/android/gi.test(navigator.userAgent)){
// todo : android
}

if (/ipad|iphone|mac/gi.test(navigator.userAgent)){
// todo : ios
}

 

 

 

<script>

$(function() {
var isIOS = (/iphone|ipad/gi).test(navigator.appVersion);
if (isIOS) {

}
});
</script>
posted @ 2014-12-26 10:58  对方屌丝正在输入中  阅读(289)  评论(0编辑  收藏  举报