js判断手机访问web网站跳转到手机版
2024-09-29 10:43:10
第一种:直接JS脚本
<script type="text/javascript">
try {
var urlhash = window.location.hash;
if (!urlhash.match("fromapp"))
{
if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
{
window.location="http://www.laozuo.org(更换成自己的WAP网站)";
}
}
}
catch(err)
{
}</script>
第二种:引用
function uaredirect(murl){
try {
if(document.getElementById("bdmark") != null){
return;
}
var urlhash = window.location.hash;
if (!urlhash.match("fromapp")){
if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i))) {
location.replace(murl);
}
}
} catch(err){}
}只要将代码放在电脑版网站一个公共包含的文件里即可
最新文章
- HDU 5055 Bob and math problem(简单贪心)
- AIX 5L 系统管理技术 —— 存储管理——物理卷
- $http服务和$location
- Android Handler机制(四)---Handler源码解析
- bzoj4400: tjoi2012 桥
- What does ";Rxlch"; mean in ENCODE?
- 安装Ubuntu 16.04后要做的事
- Hark的数据结构与算法练习之简单选择排序
- Yii 实现MySQL多库和读写分离
- eclipse 默认jdk 的设置 eclipse.ini -vm 参数
- 将markdown格式转化为bootstrap风格html
- 《HelloGitHub》第12期
- 【Darwin】 越狱后玩耍IPhone系统
- 使用boost.python封装C++库
- Day30--Python--struct, socketserver
- JS获取当前日期、比较日期大小
- python获取两个日期间的工作日
- C语言笔记变量与数据类型
- (17)Questioning the universe
- Visual Studio 2013中引入Web Service的简单方法visual studio 引用 wsdl
热门文章
- 【BZOJ】3850: ZCC Loves Codefires(300T就这样献给了水题TAT)
- 【BZOJ】2875: [Noi2012]随机数生成器(矩阵乘法+快速乘)
- HDU 4614 Vases and Flowers(线段树+二分)
- 提升 web 应用程序的性能(二)
- hdu-acm steps Monkey and Banana
- CVE-2013-3908 Internet Explorer打印预览功能可导致信息泄露
- 直接双击运行PowerShell的脚本文件
- UVA 796 Critical Links(Tarjan求桥)
- php扩展redis,编译安装redis服务
- ThinkPHP 学习笔记 ( 三 ) 数据库操作之数据表模型和基础模型 ( Model )