Re: Determining Screen Resolution

by "Peter Newton" <c-newton(at)ihug.co.nz>

 Date:  Sat, 17 Feb 2001 12:14:18 +1300
 To:  <hwg-techniques(at)hwg.org>
 References:  thewebsons
  todo: View Thread, Original
Hello BenO,

You've probably got all you need by now , but I remember asking this
question some time ago so I looked it up in my useful tips archive and found
it. Its been modified slightly to encompass browser changes and also window
resizing but here it is anyway:- (I can't remember who posted the original
script).

In the body tag I've used javascript to reload the webpage whenever the
browser window is resized in order to recalculate the new window size. (you
may NOT want to do this)


<html>
<head><title>Screen and Window Sizes</title>

<SCRIPT type="text/javascript">
<!--
function screenDetect () {
 var iw, ih; // Set inner width and height
 if (window.innerWidth == null) {
  iw = document.body.clientWidth;
  ih=document.body.clientHeight;
 }
 else {
  iw = window.innerWidth;
  ih = window.innerHeight;
 }
 document.write("SCREEN width="+screen.width+"<br>SCREEN
height="+screen.height+"<br>");
 document.write("WINDOW Width= "+iw+"<br>WINDOW Height= "+ih+"<br>");
}

// -->
</SCRIPT>

</head>
<body bgcolor="#d0d0d0" onResize="window.location.href =
window.location.href;">
<h1 align=center>Screen and Window Sizes</h1>


<SCRIPT type="text/javascript">
<!--

 screenDetect();

// -->
</SCRIPT>


</body>
</html>

Hope it helps
Peter Newton



----- Original Message -----
From: "Ben Ocean" <lists(at)TheWebsons.com>

> Hi;
> About a year ago someone posted a nifty script to determine the screen
> resolution of users' browsers. Would that person, or anyone else that has
> such a script, please share it with us again? Or, does anyone know a
> resource I could tap for such information?
> TIA,
> BenO
>
>

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA