JS判断当前浏览器来自PC或者手机

来源:互联网 发布:linux蓝牙传命令 编辑:程序博客网 时间:2024/06/15 10:54

下一步要开发手机商城了 所以就找了一段JS代码来实现判断PC和Phone实现自动跳转。

代码如下所示:

<script language="JavaScript" type="text/javascript">        {            if (navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i)) {                window.location.href = 'Phone.htm';            }             else {                window.location.href = 'PC.htm';            }        }          </script> 


0 0