我有一个客户端站点,只要视口(viewport)大小落在特定参数范围内,就会切换到移动版本:
if($(window).width() < 800) {
document.location="http://www.website.com/mobile.html";
}
但是,在各种版本的 IE 中,无论视口(viewport)宽度如何,脚本始终都会触发。我尝试了许多不同的变体,但似乎无法让它发挥作用。
感谢任何帮助。
谢谢
我
最佳答案
使用以下代码:
if($(window).outerWidth() < 800) {
window.location.href = "http://www.website.com/mobile.html";
}
关于jQuery .width() 条件始终在 IE 中触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16461725/