Javascript 重定向到移动网页

Javascript 重定向到移动网页,javascript,jquery,html,jquery-mobile,mobile,Javascript,Jquery,Html,Jquery Mobile,Mobile,我有一个网页,可以检测屏幕宽度,然后将移动用户重定向到jQuery mobile制作的移动html。但通过这种方式,一些三星手机用户似乎出现了错误,用户无法查看桌面站点。我目前的代码是: <script type="text/javascript"> <!-- if (screen.width <= 699) { document.location = "mobilehome.html"; } //--> </script> <s

我有一个网页,可以检测屏幕宽度,然后将移动用户重定向到jQuery mobile制作的移动html。但通过这种方式,一些三星手机用户似乎出现了错误,用户无法查看桌面站点。我目前的代码是:

 <script type="text/javascript">
<!--
if (screen.width <= 699) {
document.location = "mobilehome.html";
}
//-->
    </script>
    <script language=javascript>
<!--
        if(/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)){
            window.location = "http://viewplus.url.ph/mobilehome.html";}


    </script>


尝试通过分辨率或屏幕大小来确定设备是否可移动是一个坏主意,因为它们可能会有很大的差异

是一个很好的插件,它为您提供了一个对象,您可以轻松地检查用户的设备是否是移动的。只需在代码中包含此插件,然后就可以执行以下操作

if( isMobile.any ) window.location = "mobilehome.html";

针对特定设备,还有大量其他选择

不,没有任何东西说插件需要jQuery才能工作。你确定你包含的插件正确吗?另外,请参阅我答案的更新,你应该使用
窗口
对象重定向页面。