js判断手机还是pc并跳转相关页面
2016-05-11 18:36
751 查看
<script type="text/javascript"> function GetRequest() { var url = location.search; //��ȡurl��"?"������ִ� var theRequest = new Object(); if (url.indexOf("?") != -1) { var str = url.substr(1); strs = str.split("&"); for(var i = 0; i < strs.length; i ++) { theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]); } } return theRequest; } var request = new Object(); request = GetRequest(); checkWidth(); function checkWidth() { //if (undefined != request["Account"] && undefined != request["paihangbang"] && undefined != request["benlunmingci"] && undefined != request["tunshirenshu"] && undefined != request["benlunzuidatizhong"]) { // window.location.href = "share.html"+location.search; // return; //} var math = Math.floor(Math.random()*10); if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){ if(window.location.href.indexOf("?mobile")<0){ try{ if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){ }else if(/iPad/i.test(navigator.userAgent)){ }else{ } if(undefined != request["Account"] && undefined != request["id"]) { window.location.href = "index_mobile_share.html"+location.search; return; }else{ if(math <= 5){ window.location.href="index_mobile.html"+location.search; return; }else{ window.location.href="index_mobileA.html"+location.search; return; } } }catch(e){} } }else{ if(math <= 5){ window.location.href="index_PC.html"+location.search; }else{ window.location.href="index_PCA.html"+location.search; } } } </script>
相关文章推荐
- 检查字符串中出现aa字符串的所有位置
- Jsonkit报错修改
- 后台接收json对象
- 分享12个非常实用的JavaScript小技巧
- JavaScript获取CSS中样式的值
- JavaScript复习第二天元素节点的增删操作
- Javascript的DOM操作 - 你真的了解吗?
- js SyntaxError: identifier starts immediately after numeric literal
- 分享10个优化代码的CSS和JavaScript工具
- js setInterval 和setTimeout 实现多线程?
- js 数组的深浅拷贝 js对象的深浅拷贝
- JSTL C标签 <c:if>判断参数是否为空
- js之事件冒泡和事件捕获详细介绍
- JS 中 Array.slice() 和 Array.splice()方法
- JSTL中c:forEach循环里的值的substr操作及对String操作的常用API
- xStream完美转换XML、JSON
- 获取屏幕宽高
- maven项目无法使用jstl解决办法
- CI笔记6 json 传值
- JsonHelper 操作帮助类