Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1491 How do I detect a users screen resolution and send them to a page suitable for them?

You are here: irt.org | FAQ | JavaScript | Screen | Q1491 [ previous next ]

Design your website in 800x600 resolution, create a 640x480 replica and place the following code between the HEAD tags.

This will work for both Internet Explorer and Netscape v4.0 or higher.

<script language="JavaScript"><!--
var BroW = navigator.appVersion;

//check visitor screen resolution

if (BroW >= 4) {
  x = screen.width ; y = screen.height
  if (document.layers) {
    if ((x >= 800) && (x <= 1028)) {x = 1028}
    if ((y >= 600) && (y <= 780))  {y = 780}
    if ((x >= 640) && (x <= 800))  {x = 800}
    if ((y >= 480) && (y <= 600))  {y = 600}
    if (x <= 640) {x = 640}
    if (y <= 480) {y = 480}
  }
  Res = x + "x" + y
} else {
  Res = 'unknown'
}

// redirect low resolution
// replace www.mypage.com/d640x480.htm with your own host and page name
if (Res == '640 + "x" + 480')
  location.href="http://www.mypage.com/d640x480.htm";
//--></script>

Submitted by James Reidy

©2018 Martin Webb