Help with javascript popwin

starwarsdad

Golden Member
May 19, 2001
1,433
0
0
I am using a javascript popwin to open a new page displaying a full size image of a thumb nail image.

The code for the popwin.cfm is:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<cfoutput>
<head>
<title>Popwin.cfm</title>
<link href="../Common/StyleSheet.css" rel="stylesheet" type="text/css">
</head>

<body bgcolor="White" text="Black" link="005D99" vlink="005D99" alink="005D99">


<table align="center">
<tr>
<td align="center" class="pClrBody">#url.image#</td>
</tr>
<tr>
<td align="center" class="pClrBody">#url.desc#</td>
</tr>
<tr>
<td align="center"><img src="images/Lores/#url.image#.jpg" border="2" alt=""></a></td>
</tr>
<tr>
<td align="center"><a href="javascript:window.close();" class="pClrBodyBold">close window</a></td>
</tr>
</table>

</body>
</cfoutput>
</html>


I would like for the popwin to "read" the size of the image dynamically an size the pop up window accordingly.

How do I do this? I have tried Google, but my queries must have sucked, as I do not get results back that apply to my problem.

Many Thanks!
 

labgeek

Platinum Member
Jan 20, 2002
2,163
0
0
in your body tag add something like:

onload="javascript:window.resizeTo(document.img.width+25,document.img.height+25)"

Also add "name=img" to your img

Such as:
<body bgcolor="White" text="Black" link="005D99" vlink="005D99" alink="005D99" onload="javascript:window.resizeTo(document.img.width+25,document.img.height+25)" ); ">

and

<img src="images/Lores/#url.image#.jpg" border="2" alt="" name=img>

You will also need to play with the padding (+25 to both width and height in my example to suit your needs - ie toolbars, etc).

 

starwarsdad

Golden Member
May 19, 2001
1,433
0
0
DUDE!!!

That works great! I just had to pump the padding (as you suggested [150 x 50]) and it works great.

Thanks a million!