首页 > 移动平台 > 详细

通过代码实现自动判断是手机端还是PC端跳转

时间:2017-09-14 17:25:25      阅读:386      评论:0      收藏:0      [点我收藏+]
 1 <!-- 2017/09/13 跳转手机页面 start by 小鬼PSer -->
 2 <meta name="mobile-agent" content="format=html5;url=http://forbag.inrn.net/kh1m.aspx">
 3 <script type="text/javascript">
 4     var userAgentInfo = navigator.userAgent;
 5     if  (userAgentInfo.indexOf("Android") > 0 || userAgentInfo.indexOf("iPhone") > 0 || userAgentInfo.indexOf("SymbianOS") > 0 || userAgentInfo.indexOf("Windows Phone") > 0 || userAgentInfo.indexOf("iPod") > 0 || userAgentInfo.indexOf("iPad") > 0) 
 6     {
 7         window.location.href = "http://forbag.inrn.net/kh1m.aspx";
 8     }else {
 9         }
10 </script>
11 <!-- 2017/09/13 跳转手机页面 end by 小鬼PSer -->

将以上代码插入到主页源文件的区域之间,当用户在手机端输入网址http://forbag.inrn.net会直接跳入到http://forbag.inrn.net/kh1m.aspx的网页内容。

通过代码实现自动判断是手机端还是PC端跳转

原文:http://www.cnblogs.com/php-qiuwei/p/7521511.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!