手机访问pc网站自动跳转手机端网站代码
<SCRIPT LANGUAGE="JavaScript">
function mobile_device_detect(url)
{
var thisOS=navigator.platform;
var os=new Array("iPhone","iPod","iPad","android","Nokia","SymbianOS","Symbian","Windows Phone","Phone","Linux armv71","MAUI","UNTRUSTED/1.0","Windows CE","BlackBerry","IEMobile");
for(var i=0;i<os.length;i++)
{
if(thisOS.match(os[i]))
{
window.location=url;
}
}
//因为相当部分的手机系统不知道信息,这里是做临时性特殊辨认
if(navigator.platform.indexOf('iPad') != -1)
{
window.location=url;
}
//做这一部分是因为Android手机的内核也是Linux
//但是navigator.platform显示信息不尽相同情况繁多,因此从浏览器下手,即用navigator.appVersion信息做判断
var check = navigator.appVersion;
if( check.match(/linux/i) )
{
//X11是UC浏览器的平台 ,如果有其他特殊浏览器也可以附加上条件
if(check.match(/mobile/i) || check.match(/X11/i))
{
window.location=url;
}
}
//类in_array函数
Array.prototype.in_array = function(e)
{
for(i=0;i<this.length;i++)
{
if(this[i] == e)
return true;
}
return false;
}
}
mobile_device_detect("http://***.***.com");
</SCRIPT>
备注这里的
mobile_device_detect("http://***.***.com");//里面的地址填的就是您的移动端的网站地址呦。
本文出自:http://www.thinkphp.cn/extend/499.html
手机访问pc网站自动跳转手机端网站代码的更多相关文章
- 手机访问pc网站自动跳转手机端网站PHP代码
$agent = $_SERVER['HTTP_USER_AGENT']; if(strpos($agent,"comFront") strpos($agent,"iPh ...
- JS实现手机访问pc网址自动跳转到wap网站
之前写pc端直接跳转wap端一直是后端java写的,跟js一样都是根据navigator.userAgent来判断设备是电脑还是手机的,我知道这种前端也可已完成的功能,只是后台比较强势,本人本着以和为 ...
- 利用JS实现手机访问PC网址自动跳转到wap网站
方法一:使用百度siteapp中的js进行判断 <script src="http://siteapp.baidu.com/static/webappservice/uaredirec ...
- 手机端页面访问PC页面自动跳手机端代码
<script> var mobileAgent = new Array("iphone", "ipod", "ipad", & ...
- PC端网站跳转手机端网站
<SCRIPT LANGUAGE="JavaScript"> function mobile_device_detect(url) { var thisOS=navig ...
- 手机访问PC网站自动跳转到手机网站代码(转)
4G时代,手机网站已经非常普遍了,一般手机网站都有一个二级域名来访问,比如 m.16css.com 如果手机直接访问www.16css.com 就是PC网站,在手机上浏览电脑版网站体验非常不好. 如果 ...
- 手机访问PC网站自动跳转到手机网站代码
方法一: <script type="text/javascript"> try { var urlhash = window.location.hash; if (! ...
- 通过PHP自带的$_SERVER判断 手机访问网站自动跳转到手机版
需要有PC版网站和移动版网站,当手机访问域名的时候,通过PHP自带的$_SERVER判断浏览设备并跳转到移动版页面.如果是PC电脑打开网址,则不跳转直接访问pc版. <?php //php判断客 ...
- 手机设备访问PC页面如果跳转到手机页面?
//例如:iphone访问www.baidu.com自动跳转到wap.baidu.com,只需在pc端模版页面引入以下js代码//pc zhuan mobile var mobileAgent = n ...
随机推荐
- Boost练习程序(multi_index_container)
代码来自:http://blog.csdn.net/whuqin/article/details/8482547 该容器能实现多列索引,挺好. #include <string> #inc ...
- HDU 5869 Different GCD Subarray Query 离线+树状数组
Different GCD Subarray Query Problem Description This is a simple problem. The teacher gives Bob a ...
- hdu 4784 Dinner Coming Soon(spfa + 优先队列)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4784 思路:建图,对于同一个universe来说,就按题目给的条件相连,对于相邻的universe,连 ...
- hdu 4114(状压dp)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4114 思路:首先是floyd预处理出任意两点之间的最短距离.dp[state1][state2][u] ...
- JS获得鼠标位置
<body> <script> function mouseMove(ev) { ev = ev || window.event; var mousePos = mouseCo ...
- Visual Studio工具栏中无法选择调试设备
Visual Studio工具栏中无法选择调试设备 在Visual Studio工具栏中,默认显示已经识别的设备.用户可以从中选择对应的设备,进行调试和部署App.但是由于误操作,可能导致该选项丢失. ...
- 02 CSS/javaScript
CSS(Cascading Style Sheets)是层叠样式表用来设置网页的显示效果.可以解决html代码对样式定义的重复,提高了后期样式代码的可维护性,并增强了网页的显示效果功能.简单一句话:C ...
- hdu 1114 Piggy-Bank
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission( ...
- underscore.js依赖库函数分析二(查找)
查找: 在underscore.js封装了对dom查找的操作,find()和filter()函数,find()函数的查找操作是返回首个与条件相符的元素值,filter()函数是找到与条件相符的所有元素 ...
- Oracle查询每天固定时间段的数据
select * from GPS_LOG t where to_char(t.gps_time,'hh24:mm:ss')>='15:30:00'and to_char(t.gps_time, ...