一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

js判断手机访问还电脑访问网站

时间:2013-04-18 编辑:简简单单 来源:一聚教程网

用户是手机访问还是电脑方法

 代码如下 复制代码

var is_iPd = navigator.userAgent.match(/(iPad|iPod|iPhone)/i) != null;
var is_mobi = navigator.userAgent.toLowerCase().match(/(ipod|iphone|android|coolpad|mmp|smartphone|midp|wap|xoom|symbian|j2me|blackberry|win ce)/i) != null;
if(is_mobi && window.location.search.indexOf("mv=fp")<0){
window.location.href="#";
}

浏览器类型

 代码如下 复制代码

if(navigator.userAgent.indexOf("MSIE")>0){
   //ie
   }else if(navigator.userAgent.indexOf("Firefox")>0){
   //firefox
   }else if(navigator.userAgent.indexOf("Chrome")>0){
   //chrome
   }else if(navigator.userAgent.indexOf("Safari")>0){
   //safari
   }else{
   //this part can be used as opera area
   }

热门栏目