【发布时间】:2013-10-14 16:27:58
【问题描述】:
我实际上做了一个带有移动版本的网站(在另一个带有第二个 index.html 的文件夹中)
我已使用此脚本将移动设备从桌面版重定向到移动版
if ( navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/iPad/i) ){
window.location.href = "http://m.website.net" + document.location.hash;
}
这很好,但问题是共享移动版本的人会将人们发送到移动设备,因为移动网址。所以我尝试像这样将它们自动重定向到桌面版本
if (! navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/iPad/i) ){
window.location.href = "http://www.website.net" + document.location.hash;
}
这在 iphone 上工作但用 ipad 创建了一个无限循环,请问我该怎么做? 我只能使用 javascript 来做到这一点
我不能像这样使用脚本
if (screen.width <= 960) {document.location = mobile.html";}
因为 ipad 视网膜等分辨率
【问题讨论】:
标签: javascript ipad mobile detection