homepage Welcome to WebmasterWorld Guest from 54.211.7.174
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
resizing the window based on the size of the image
resizing the window based on
luckydude




msg:1473235
 10:06 pm on Jan 6, 2004 (gmt 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

 

HocusPocus




msg:1473236
 11:39 pm on Jan 6, 2004 (gmt 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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved