[thelist] NS 7.0 ScreenSize Bug

Peter-Paul Koch gassinaumasis at hotmail.com
Thu Dec 5 09:43:01 CST 2002

>The script to capture screen resolution is the last two lines inserted
>in the setfocus procedure.  Values are saved in hidden input fields and
>PUT to the server with the form is submitted.
><script language="JavaScript">
>function setfocus (input) {
>   input.focus();
>   if (input.createTextRange) {
>     var range = input.createTextRange();
>     range.collapse(true);
>  range.expand("textedit");
>     range.select();
>     document.LoginForm.strResWidth.value = window.screen.availWidth;
>     document.LoginForm.strResHeight.value  = window.screen.availHeight;
>   }
>It's worked fine in every browser I tested, except Netscape 7.0.  It
>seems no values are stored for strResWidth or Height.

Mozilla doesn't support createTextRange. I assume you only tested the script
in various versions of Explorer.

Move the writing of the availHeight outside the if (input.createTextRange)
and it should work.

ppk, freelance web developer
Interaction, copywriting, JavaScript, integration
Column "Keep it Simple": http://www.digital-web.com/columns/keepitsimple/
What shall we do with the W3C DOM?:

STOP MORE SPAM with the new MSN 8 and get 2 months FREE*

More information about the thelist mailing list