Home | All Questions | alt.html FAQ > Client-side Windows Scripting

How do I redirect a page based on screen resolution?

Be warned. Screen Resolution is not the same as browser width.

<script type="text/javascript">
if(screen.width<800) {
 document.location="small.html";
}
if(screen.width>1100) {
 document.location="big.html";
}
document.location="medium.html";
</script>

If you want to redirect based on browser window size, then:

<script type="text/javascript">
if (window.clientWidth < 800) {
 document.location="small.html";
}
if (window.clientWidth > 1100) {
 document.location="big.html";
}
document.location="medium.html";
</script>

Recommended Resources

Discussion

Related Questions