码迷,mamicode.com
首页 > 移动开发 > 详细

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

时间:2017-09-14 18:41:19      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:跳转   手机   inf   tin   通过   and   agent   javascrip   back   

 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端跳转

标签:跳转   手机   inf   tin   通过   and   agent   javascrip   back   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!