js判断手机浏览器操作系统和微信浏览器的方法
做手机端的前端开发,少不了对手机平台的判断。如,对于app下载,就要判断在Android平台下就显示Android下载提示;在iOS平台下就显示iOS下载提示。
今天就为大家介绍一下用js判断手机客户端平台及系统平台的方法:
<script type="text/javascript">
//手机端判断各个平台浏览器及操作系统平台
function checkPlatform(){
if(/android/i.test(navigator.userAgent)){
document.write("This is Android'browser.");//这是Android平台下浏览器
}
if(/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)){
document.write("This is iOS'browser.");//这是iOS平台下浏览器
}
if(/Linux/i.test(navigator.userAgent)){
document.write("This is Linux'browser.");//这是Linux平台下浏览器
}
if(/Linux/i.test(navigator.platform)){
document.write("This is Linux operating system.");//这是Linux操作系统平台
}
if(/MicroMessenger/i.test(navigator.userAgent)){
document.write("This is MicroMessenger'browser.");//这是微信平台下浏览器
}
}
$(document).ready(function(){
alert(navigator.platform);
checkPlatform();
});
</script>
在这里就不做pc端操作系统平台的判断了,怎么判断也说下方法,如用document.write(navigator.platform);就可以获得操作系统平台。在win32下就会显示Win32,;在Win64下就会显示Win64等。
from:http://www.wufangbo.com/js-shou-ji-wei-xin/
js判断手机浏览器操作系统和微信浏览器的方法的更多相关文章
- PHP和js判断访问设备是否是微信浏览器实例
PHP和js判断访问设备是否是微信浏览器实例,代码非常精简,适合新手学习. js判断是否是微信浏览器: 1 function is_weixin() { 2 var ua = window.navig ...
- js判断是否使用的是微信浏览器
代码如下: function is_weixin() { var ua = navigator.userAgent.toLowerCase(); return ua.match(/MicroMesse ...
- PHP和js判断访问终端是否是微信浏览器
http://www.sucaihuo.com/php/813.html http://www.thinkphp.cn/extend/767.html http://blog.csdn.net/gf7 ...
- js判断手机是的操作系统
var browser = { versions: function() { var u = navigator.userAgent, app = navigator.appVersion; retu ...
- js判断手机端操作系统(Andorid/IOS)
非常实用的js判断手机端操作系统(Andorid/IOS),并自动跳转相应下载界面 androidURL = "http://xxx/xxx.apk"; var browser = ...
- js判断手机 横屏模式
js判断手机 横屏模式 方法名称:orientation 实例: if(window.orientation!=0){ var obj=document.getElementById('orienta ...
- app分享时判断手机是否已安装微信或QQ客户端
/** * 判断 用户是否安装微信客户端 */ public static boolean isWeixinAvilible(Context context) { final PackageManag ...
- php检测当前浏览器是否为微信浏览器
<?php /** php检测当前浏览器是否为微信浏览器 */ function is_weixin_browser(){ if(strpos($_SERVER['HTTP_USER_AGENT ...
- javascript检测当前浏览器是否为微信浏览器
<!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8& ...
随机推荐
- 自动计算label字体的高度和图片拉伸处理(封装成分类分享)
自动计算label字体的高度和图片拉伸处理 *:first-child { margin-top: 0 !important; } body > *:last-child { margin-bo ...
- 【原】Redis基本操作
Redis基本操作 遍历操作 Pub-Sub server Lua脚本 Redis中的这些操作都是不分大小写的. 除了针对于具体类型的具体操作.还有一些其他操作. 遍历操作 SCAN cursor [ ...
- maven,spring,mybatis集成错误
maven,spring,mybatis集成的时候单元测试junit测试没问题,但mvn jetty:run 就报错误 错误: org.apache.ibatis.binding.BindingExc ...
- Eclipse创建Maven Web项目 + 测试覆盖率 + 常见问题(2015.07.14——湛耀)
Eclipse创建Maven web项目: 到此,并没有创建好,接下来一步步解决问题: 问题:无法创建src/main/java目录 解决: 右键项目选择[properties] 点击[OK] 问题: ...
- Hadoop InputFormat浅析
本文转载:http://hi.baidu.com/_kouu/item/dc8d727b530f40346dc37cd1 在执行一个Job的时候,Hadoop会将输入数据划分成N个Split,然后启动 ...
- Go Slices: usage and internals
Introduction Go's slice type provides a convenient and efficient means of working with sequences of ...
- URAL 1994 The Emperor's plan 求组合数 大数用log+exp处理
URAL 1994 The Emperor's plan 求组合数 大数用log #include<functional> #include<algorithm> #inclu ...
- eclipse调试的基本意义
step into就是单步执行,遇到子函数就进入并且继续单步执行: step over是在单步执行时,在函数内遇到子函数时不会进入子函数内单步执行,而是将子函数整个执行完再停止,也就是把子函数整个作为 ...
- sping获取bean方法 解决资源耗尽
// ApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"applicationCon ...
- Map集合中value()方法与keySet()、entrySet()区别
http://blog.csdn.net/liu826710/article/details/9001254 在Map集合中 values():方法是获取集合中的所有的值----没有键,没有对应关系, ...