微信

javascript 判断是否是PC还是手机端

function IsPC() { 
   var userAgentInfo = navigator.userAgent; 
   var Agents = new Array("Android", "Linux","iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"); 
   var flag = true; 
   for (var v = 0; v < Agents.length; v++) { 
       if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; } 
   } 
   return flag; 
}

注释:

如果  flag  返回 false;     手机端  
   flag 返回 turn PC端;

if(IsPC()){
    var size =0.5,title = document.title ;
    document.querySelector('.scene_title').innerHTML=title;
    document.querySelector('.p-index').style.cssText = "position:relative;height:486px;overflow:hidden;cursor:pointer";
    
}else{
    $("#code").remove();
    $('.p-index').clone().appendTo($("body"));
    $(".phone_panel").remove();
    document.querySelector('.p-index').style.height = (document.body.clientHeight ||  document.documentElement.clientHeight )+"px"
}

 

posted @ 2015-01-26 10:02  Admin_info  阅读(212)  评论(0编辑  收藏  举报
青春时代是一个短暂的美梦,当你醒来时,这早已消失得无影无踪了。
点点Admin_info