js判断客户端是pc端还是移动端

$(function() {
	if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {  
	  //alert(navigator.userAgent);    
	   window.location.href ="iPhone.html";  
	} else if (/(Android)/i.test(navigator.userAgent)) {  
	  //alert(navigator.userAgent);   
	   window.location.href ="https://hao.360.cn/";  
	} else {  
	  window.location.href ="https://web.sogou.com/?11621";  
	};  

})

  

//判断系统是不是ios
function isIos() {
  //拿到用户信息
  var userAgentInfo = navigator.userAgent;
  var Agents = 'iPhone';
  if(userAgentInfo.indexOf(Agents) > 0) { //如果是ios
    return true;
  } else { //不是ios
    return false;
  }
}

  

posted @ 2018-03-28 22:34  南夏啊南夏  阅读(255)  评论(0编辑  收藏  举报