Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

resizing the window based on the size of the image

resizing the window based on



10:06 pm on Jan 6, 2004 (gmt 0)

10+ Year Member

hi there,
I am new to JavaScript. I know how to resize and place a new window using JavaScript. Here is the code below

function openwindow()

But the problem is, I have many images on my page and unfortunately, they are not the same size (300 x 350) So, how can a write a function that will recognize the size of the image and display the right size of a new window? I would really appreciate if you could help me. Thanks in advance.



11:39 pm on Jan 6, 2004 (gmt 0)

10+ Year Member

Assuming there is only one image on the opened window page, if you use this code in the opened window it should work for most Javascript enabled browsers I think.

<body onload="resizeTo(document.images[0].width,document.images[0].height);" ...

you might need to add a bit of padding.


Featured Threads

Hot Threads This Week

Hot Threads This Month