Redirect based on screen resolution with jQuery?
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
if ($(window).width() <= 1024) location.href = "1024.html";
docs on width()
$(document).ready(function() {
if (screen.width >= 1024) {
window.location.replace("http://example.com/1024.html");
}
else {
window.location.replace("http://example.com/index.html");
}
});
Reference notes in the answer to this question on difference between window.location.replace
and window.location.href
.