jquery判断移动设备代码片段;pc、iphone、安卓
$(document).ready(function () {
/* 判断设备*/
var browser={
versions:function(){
var u = navigator.userAgent, app = navigator.appVersion;
return {
trident: u.indexOf('Trident') > -1, //IE内核
presto: u.indexOf('Presto') > -1, //opera内核
webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1,//火狐内核
mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或者uc浏览器
iPhone: u.indexOf('iPhone') > -1 , //是否为iPhone或者QQHD浏览器
iPad: u.indexOf('iPad') > -1, //是否iPad
webApp: u.indexOf('Safari') == -1, //是否web应该程序,没有头部与底部
weixin: u.indexOf('MicroMessenger') > -1, //是否微信 (2015-01-22新增)
qq: u.match(/\sQQ/i) == " qq" //是否QQ };
}(),
language:(navigator.browserLanguage || navigator.language).toLowerCase()
}
if (window.orientation == 0 || window.orientation == 180 || window.orientation == 90 || window.orientation == -90) {
if (window.orientation == 0 || window.orientation == 180) {
$("body").attr("class", "portrait");
orientation = 'portrait';
if(browser.versions.android||browser.versions.iPhone||browser.versions.iPad){ window.location.href = "mobile.html";}else{ } return false;
} }
$(window).bind( 'orientationchange', function(e){
if (window.orientation == 0 || window.orientation == 180 || window.orientation == 90 || window.orientation == -90) {
if (window.orientation == 0 || window.orientation == 180) {
$("body").attr("class", "portrait");
orientation = 'portrait';
if(browser.versions.android||browser.versions.iPhone||browser.versions.iPad){ window.location.href = "mobile.html";}else{ } return false;
} i }
}); });
jquery判断移动设备代码片段;pc、iphone、安卓的更多相关文章
- 不可错过的10个超棒jQuery表单操作代码片段
jQuery 绝对是一个伟大的开源javascript类库,是帮助我们快速和高效开发前端应用的利器.可能大家在日常的开发过程中常常会处理表单相关的 javascript,在今天这篇代码片段分享文章中, ...
- 10 个实用的 jQuery 表单操作代码片段
jQuery 绝对是一个伟大的开源JavaScript类库,是帮助我们快速和高效开发前端应用的利器.可能大家在日常的开发过程中常常会处理表单相关的 JavaScript,在今天这篇代码片段分享文章中, ...
- 10个超棒jQuery表单操作代码片段
jQuery绝对是一个伟大的开源javascript类库,是帮助我们快速和高效开发前端应用的利器.可能大家在日常的开发过程中常常会处理表单相关的javascript,在今天这篇代码片段分享文章中,这里 ...
- jquery 判断当前设备是PC端还是移动端
$(function(){ var system = { win: false, mac: false, xll: false, ipad:false }; //检测平台 var p = naviga ...
- jquery判断当前设备是手机还是电脑并跳转
<script type="text/javascript"> var commonURL = 'http://xxxx.com/'; function mobile_ ...
- 如何判断 ios设备的类型(iphone,ipod,ipad)
功能函数: -(bool)checkDevice:(NSString*)name { NSString* deviceType = [UIDevice currentDevice].model; NS ...
- (原) Jquery 判断移动设备是IOS / Android系统
var u = navigator.userAgent; var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > - ...
- Jquery判断IE6等浏览器的代码
这好像是由几篇代码接在一起的,原文均来自网络,不记得出处了~ jquery中利用navigator.userAgent.indexOf来判断浏览器类型,并进行了一下处理,如果不想使用jquery,稍为 ...
- PHP简单判断手机设备的方法
本文实例讲述了PHP简单判断手机设备的方法.分享给大家供大家参考,具体如下: 现在移动互联网越来越发到,很多的网站都普及了手机端浏览,为了更好的让网页在手机端显示,我们都选择了使用CSS媒体查询制作响 ...
随机推荐
- MySql的一些问题
问题1:卸载重装mysql时,报1045和2003错误. 解决:点击skip,跳过这个错误.进到my.ini,在mysqld下面加一句:skip-grant-tables,保存.重启mysql服务,在 ...
- TCP粘包拆包问题
阿π 专注于网络协议,系统底层,服务器软件 C++博客 | 首页 | 发新随笔 | 发新文章 | | | 管理 Socket粘包问题 这两天看csdn有一些关于socket粘包,socket缓冲区设置 ...
- 正则语言(转的 大额_skylar )
备注:正则表达式真的很头疼,收集起来,用起来很方便的. 常用的元字符 . 匹配除换行符以外的任意字符 \w 匹配字母或数字或下划线或汉字 \s 匹配任意的空白符 \d 匹配数字 \b 匹配单词的开始或 ...
- jQuery学习-事件之绑定事件(七)
今天来说说事件中的handlers方法中的一个片段 1 matches[ sel ] = handleObj.needsContext ? 2 jQuery( sel, this ).in ...
- css案例学习之并集选择器
代码 <html> <head> <title>并集选择器</title> <style type="text/css"> ...
- POJ 3662 Telephone Lines(二分答案+SPFA)
[题目链接] http://poj.org/problem?id=3662 [题目大意] 给出点,给出两点之间连线的长度,有k次免费连线, 要求从起点连到终点,所用的费用为免费连线外的最长的长度. 求 ...
- Android UI ActionBar功能-Action Bar 左上角的向上或返回按钮
ActionBar在左上角还提供了一个向上或返回的按钮,默认情况下是隐藏的需要在代码中开启: 官方文档:http://wear.techbrood.com/training/basics/action ...
- javascript第六课类型转换
1.parseint(参数): 转换为整数,即使参数中的字符串包含字母数字混合,此方法也会自动一个一个判断和转换 parseInt(参数,进制);将参数通过几进制的方式转为数字 2.parsefl ...
- How to set custom JsonSerializerSettings for Json.NET in MVC 4 Web API?
ou can customize the JsonSerializerSettings by using theFormatters.JsonFormatter.SerializerSettings ...
- C++Primer 中间Sales_items.h头文件
#ifndef SALESITEM_H #define SALESITEM_H #include <iostream> #include <string> class Sale ...