使用jQuery基于屏幕分辨率重定向?

Kar*_*raw 6 html css xhtml jquery

是否可以使用JQuery根据用户的屏幕分辨率重定向到不同的index.html?例如,1024px宽的屏幕到1024.html,其他所有屏幕都转到普通的index.html?

我最好喜欢使用jQuery.任何帮助将不胜感激!

谢谢!

Ada*_*dam 4

你不需要 jQuery。

您可以使用screen.width它适用于所有浏览器

if (screen.width <= 1024) window.location.replace("http://www.example.com/1024.html")
else window.location.replace("http://www.example.com/index.html")
Run Code Online (Sandbox Code Playgroud)

请参阅http://www.dynamicdrive.com/dynamicindex9/info3.htm