var ua = navigator.userAgent;
var ipad = ua.match(/(iPad).*OS\s([\d_]+)/),
isIphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/),
isAndroid = ua.match(/(Android)\s+([\d.]+)/),
isMobile = isIphone || isAndroid;
if(isMobile) {
location.href = 'http://m.domain.com';
}else{
location.href = 'http://www.domain.com';

//或者单独判断iphone或android
if(isIphone){
//code
else if(isAndroid){
//code
}else{
//code
}

  

js简化判断是否为手机访问的更多相关文章

  1. PHP网站 通过js方式判断是否是手机访问,若是 跳转到手机版网址!

    <script type="text/javascript" src="http://i3.dukuai.com/ui/js/jquery-1.32pack.js& ...

  2. 通过JS语句判断WEB网站的访问端是电脑还是手机

    通过JS语句判断WEB网站的访问端是电脑还是手机,以显示不同的页面! 目录腾讯网的适配代码如何判断访问网站的机器类型-如何判断ipadJS 判断浏览器客户端类型(ipad,iphone,android ...

  3. js判断是否为手机访问

    JavaScript判断浏览器类型一般有两种办法,一种是根据各种浏览器独有的属性来分辨,另一种是通过分析浏览器的userAgent属性来判断的.在许多情况下,值判断出浏览器类型之后,还需判断浏览器版本 ...

  4. onethink判断是否是手机访问?

    第一步:找到:Application / Common / Common / function.php 添加判断是否是手机访问的代码: /** * 判断当前访问的用户是 PC端 还是 手机端 返回tr ...

  5. C#判断用户是手机访问还是PC访问

    今天在做一个wap网站时,需要限制PC用户访问.网上找了很多资料,效果都不怎么理想.其实原理就是根据HTTP_USER_AGENT判断检查用户在用什么浏览器,再根据业务做相应的逻辑处理. 代码如下: ...

  6. PHP CodeBase: 判断用户是否手机访问(转)

    随着移动设备的普及,网站也会迎来越来越多移动设备的访问.用适应PC的页面,很多时候对手机用户不友好,那么有些时候,我们需要判断用户是否用手机访问,如果是手机的话,就跳转到指定的手机友好页面.这里就介绍 ...

  7. PHP CodeBase: 判断用户是否手机访问

    随着移动设备的普及,网站也会迎来越来越多移动设备的访问.用适应PC的页面,很多时候对手机用户不友好,那么有些时候,我们需要判断用户是否用手机访问,如果是手机的话,就跳转到指定的手机友好页面.这里就介绍 ...

  8. php 判断是否 是手机访问

    //判断是否属手机 function is_mobile() { $user_agent = $_SERVER['HTTP_USER_AGENT']; $mobile_agents = Array(& ...

  9. PHP判断用户是否手机访问

    自定义的函数如下: $agent = check_wap(); if( $agent ) { header('Location: http://www.nowamagic.net'); exit; } ...

随机推荐

  1. paramiko与MySQL数据库

    一.paramiko 1.利用paramiko连接远端服务器 import paramiko ssh = paramiko.SSHClient() ssh.set_missing_host_key_p ...

  2. [Altera]PLL仿真

    EDA Tools: 1.Quartus II 13.1(64-bit) 2.Modelsim SE-64 10.1c Time: 2016.05.05 ----------------------- ...

  3. APS.net controller

    在controller 路由配置为: routes.MapRoute( name:"Default", url:"{controller}/{action}/{id}&q ...

  4. spring mvc 定时器

    1.下载quartz-all-1.7.3.jar包 a.在Spring配置和Quartz集成内容时,有两点需要注意 b.在<Beans>中不能够设置default-lazy-init=&q ...

  5. 误差曲线(Matlab)

    loglog(dof(:),errorestimate(:),:),errorestimate1(:),);hold on; loglog(dof(:),eigvalue(:)-[);%[13.086 ...

  6. 关于prototype和__proto__ 以及 constructor的文字总结

    //函数的construct 指向了 function Function(){} undefined //实例化的对象 constructor 指向 函数本身 undefined //每个函数都有pr ...

  7. taiyi_interview(Introduction To Database Refactoring)

    Introduction To Database Refactoring 原文链接:by Scott W. Ambler:http://www.tdan.com/view-articles/5010/ ...

  8. 升级到macos sierra xcode8 requires additional components to support runing and debugging choose Install to add required components

    升级到macos sierra xcode8 报提示:requires additional components to support runing and debugging choose Ins ...

  9. MINA系列学习-mina整体介绍

    今天的这一节,将从整体上对mina的源代码进行把握,网上已经有好多关于mina源码的阅读笔记,但好多都是列举了一下每个接口或者类的方法.我倒是想从mina源码的结构和功能上对这个框架进行剖析.源码的阅 ...

  10. jQuery Mobile 网格布局

    jQuery Mobile 布局网格 jQuery Mobile 提供了一套基于 CSS 的列布局方案.不过,一般不推荐在移动设备上使用列布局,这是由于移动设备的屏幕宽度所限. 但是有时你需要定位更小 ...