Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect based on screen resolution with jQuery?

Is it possible, using JQuery, to redirect to a different index.html based upon the users screen resolution? So for example, screens upto the size 1024px wide go to 1024.html, and all others go to the normal index.html?

Id preferably like to use jQuery for this. Any help would be greatly appreciated!

Thanks!

like image 713
Karlgoldstraw Avatar asked Nov 23 '10 23:11

Karlgoldstraw


1 Answers

You don't need jQuery.

You can use screen.width, which works in all browsers:

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

See http://www.dynamicdrive.com/dynamicindex9/info3.htm

like image 123
Adam Avatar answered Oct 13 '22 12:10

Adam