Welcome to WebmasterWorld Guest from 184.72.177.182

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)

New User

10+ Year Member

joined:Jan 3, 2004
posts:40
votes: 0


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

<script>
function openwindow()
{
window.open("http://www.blahblah.com","my_new_window","width=300,height=3500,top=0,left=0")
}
</script>

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.

luckydude
WA

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

Junior Member

10+ Year Member

joined:Dec 27, 2002
posts:125
votes: 0


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.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members