[Javascript] resizing a new window
Peter-Paul Koch
gassinaumasis at hotmail.com
Sat Jul 7 12:06:33 CDT 2001
>function openNewWindow(filenm,rsz)
>{
>var opt;
>opt='menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=y
>es,resizable='+rsz+',dependent=yes,width=100,height=100';
>thewd=window.open(filenm,"",opt);
>thewd.resizeTo(thewd.document.images[0].width,
>thewd.document.images[0].height);
> }
>
>It works with IE 5.01 but it doesn't with Netscape communicator 4.77.
>With Netscape, the window is opened, the image is shown but the window is
>not resized.
>
>The error is : thewd.document.images[0] has no properties
>
>If I check thewd.document.images.length, I get 1 with IE but 0 with
>Netscape.
>
>If I do the resize in the page whose URL is passed in the filenm parameter,
>it works.
The problem is that you try to resize the page immediately after it is
requested (and before it is finished loading). In NN4, the document.images
array does not exist until the page has been completely loaded, so when you
ask about an image it says the image is not (yet) present.
If you want this to work in NN4, put the resize script in the popup page and
execute it onLoad.
ppk
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
More information about the Javascript
mailing list