Re: Javascript problem in Firefox
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: Javascript problem in Firefox

From: Jim Davis <newsmonkey@vboston.com>
Date: Wed Aug 31 2005 - 23:49:59 CEST

"Lasse Reichstein Nielsen" <lrn@hotpop.com> wrote in message
news:ll2hopy2.fsf@hotpop.com...
> "Jim Davis" <newsmonkey@vboston.com> writes:
>
>> document.getElementsByTagName('BODY')[0].clientHeight
>
> Why this convoluted way of getting at document.body? I don't think
> there is a browser implementing document.getElementsByTagName and not
> document.body (document.body was implemented by IE 3) both are part of
> the W3C DOM level 1 HTML standard).

Is there there any better answer than "that's what worked off the top of my
head"? ;^)

Isn't the great thing about JavaScript that there's ALWAYS another way (and
usually a better way) to do something?

> The clientHeight property is not standardized (it was introduced by IE
> 4), nor is its position on the body element. If one wants to find the
> size of the browser's document viewport, the FAQ has more general ways
> of doing it: <URL:http://jibbering.com/faq/#FAQ4_9>

Then, by all means, use the better code. As I noted, I only tested on IE 6x
and FireFox 1x (clientHeight is supported in both).

The primary point was NOT to use the screen size for such a decision.

>> Of course just because their browser STARTS at that size is no reason to
>> assume that they'll leave it that size for the duration of their session.
>
> Ah, yes. The devil is in the details, too.
> At least, after a page has loaded, the user can see what he is doing by
> resizing it.

Exactly... really until you constantly check for changes you're making broad
assumptions about an environment with one check. From a usability POV this
is just isn't good.

Jim Davis
Received on Tue Oct 18 03:15:35 2005