How can I determine the screen resolution a visitor is using?
Problem: Visitors may view your web site with their monitor set at different screen resolutions. The two most common ones are 800x600 and 1024x768. You may want to create specific, unique pages in your web site tailored to display properly in different screen resolutions.
To do this, you need to determine which screen resolution your visitor is using, and you can then automatically direct them to the appropriate page.
Now let's see what code we need to have our web site automatically go to a specific page based on the visitor's screen resolution. The code listed is NOT exactly what was posted in the PCMag article, as I found corrected some coding logic errors:
<script>
<!--
if (screen.width<=640)
location.href="size640.htm";
else if (screen.width<=800)
location.href="size800.htm";
else if (screen.width<=1024)
location.href="size1024.htm";
else location.href="size1280.htm";
//-->
</script>
Step 3:
Let's see if it really works!
Click here to go to page based on your current screen resolution