Re: JavaScript Problem

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

 Date:  Sat, 10 Mar 2001 20:56:16 +1300
 To:  <hwg-techniques(at)hwg.org>
 References:  thewebsons thewebsons2
  todo: View Thread, Original
I had this same problem a short time ago and went to the javascript source
website:-

http://javascriptsource.com

and had a look at some of the code used their and found the following:-
where they use

document.body.clientWidth;  and
document.body.clientHeight;

instead of

window.innerWidth  etc

which used to work for me under older browsers. Whether this is more or less
compatible than using:-

window.self.innerWidth etc

I don't know. Perhaps someone can throw some more light on this

example:-

<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>


Peter Newton

----- Original Message -----

> At 08:41 PM 3/9/2001 +0000, you wrote:
> > > Why does this variable come back undefined?
> >
> >Because Internet Explorer doesn't support it.  Check out PPK's excellent
> >page on window properties: http://www.xs4all.nl/~ppk/js/winprop.html
>
> Actually, it does, and that link showed me what I was missing!
>
> > >  >>>
> > > <html><body>
> > > <script language="javascript">
> > > document.write("Window width is: " + window.innerWidth);
>
> oops, *window.self.innerWidth*
> Thanks!
> BenO
>
>

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