<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
&nbsp;
<p>> I am opening a pop up window that displays an image. I need the window
<br>> to be the exact size of the image. Is there a way to do this without
<br>> knowing how big the image is going to be?
<br>&nbsp;
<p>The file myimage.htm is popped and in MSIE will resize itself to fit
the image
<br>Image url is sent as query string (without any "name=" tag)
<br>Here the image URLs are just file names but they may need to be longer
or even full http addresses
<p>Thanks to Peter-Paul Koch &lt;gassinaumasis@hotmail.com>
<br>for the onload code
<p>I have put the onload code into a function to reduce the risk of email
line breaks causing anyone copying the code a problem.
<br>&nbsp;
<p><b>Popper.htm</b>
<p><tt>&lt;html>&lt;head></tt>
<br><tt>&lt;title>Popper&lt;/title></tt>
<br><tt>&lt;script language="JavaScript"></tt>
<br><tt>&lt;!--</tt><tt></tt>
<p><tt>function openIMGwin(imgURL) {</tt>
<br><tt>var Wname = "popped";</tt>
<br><tt>var exec = 'window.open("';</tt>
<br><tt><font color="#3366FF">// Set name of </font><font color="#009900">common
html file</font><font color="#3366FF"> here</font></tt>
<br><b><tt>var URL&nbsp;&nbsp; = "<font color="#009900">myimage.htm</font>?"+imgURL;</tt></b>
<br><tt>exec+= URL;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exec+= '", "';</tt>
<br><tt>exec+= Wname;&nbsp;&nbsp;&nbsp; exec+= '", "';</tt>
<br><tt><font color="#3366FF">// default dimensions set next line</font></tt>
<br><tt>exec+='width=400,height=400';</tt>
<br><tt><font color="#3366FF">// 0,0 positions to top left</font></tt>
<br><tt><font color="#3366FF">// top=0,left=0 does for MSIE</font></tt>
<br><tt><font color="#3366FF">// screenX=0,screenY=0 does for Netscape</font></tt>
<br><tt><font color="#3366FF">// other attributes set for a very plain
window</font></tt>
<br><tt><font color="#3366FF">// note that resizable=1 because</font></tt>
<br><tt><font color="#3366FF">// Netscape 4.x users will have to resize
manually</font></tt>
<br><tt><font color="#3366FF">// NN6.x ??</font></tt>
<br><tt>exec+=',top=0,left=0,screenX=0,screenY=0,toolbar=0,location=0';</tt>
<br><tt>exec+=',directories=0,resizable=1,status=0,menubar=0,scrollbars=0")';</tt>
<br><tt>// eval() takes the string called exec built and executes as code</tt>
<br><tt>eval (exec);</tt>
<br><tt>}//</tt><tt></tt>
<p><tt>//--end--></tt>
<br><tt>&lt;/script></tt>
<br><tt>&lt;/head></tt>
<br><tt>&lt;body></tt>
<br><tt><font color="#993300">&lt;!-- sort out your own image file names
--></font></tt>
<br><tt>&lt;a href="<A HREF="javascript:openIMGwin('aaa.jpg">javascript:openIMGwin('aaa.jpg</A>')">aaa.jpg&lt;/a>&lt;br></tt>
<br><tt>&lt;a href="<A HREF="javascript:openIMGwin('bbb.jpg">javascript:openIMGwin('bbb.jpg</A>')">bbb.jpg&lt;/a>&lt;br></tt>
<br><tt>&lt;/body>&lt;/html></tt>
<p><b>myimage.htm</b>
<p><tt>&lt;html>&lt;head></tt>
<br><tt>&lt;title>Image&lt;/title></tt>
<br><tt>&lt;/head></tt>
<br><tt>&lt;body onLoad="resizingWindow();"></tt>
<br><tt>&lt;script language="JavaScript"></tt>
<br><tt>&lt;!--</tt>
<br><b><tt>function resizingWindow(){</tt></b>
<br><b><tt>if(self.resizeTo)</tt></b>
<br><b><tt>&nbsp;{self.resizeTo(document.images[0].width,</tt></b>
<br><b><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
document.images[0].height);}</tt></b>
<br><b><tt>}//</tt></b><tt><font color="#3366FF"></font></tt>
<p><tt><font color="#3366FF">// Write Image tag with URL from search string</font></tt>
<br><tt><font color="#3366FF">// substring(1) to skip the leading '?'</font></tt>
<br><b><tt>document.write('&lt;IMG src="',</tt></b>
<br><b><tt>&nbsp; window.location.search.substring(1),'">');</tt></b><tt></tt>
<p><tt>//--end--></tt>
<br><tt>&lt;/script></tt><tt></tt>
<p><tt>&lt;/body>&lt;/html></tt>
<p>--
<br>Shop@ssistant Add-ons and Developer Workshops
<br><A HREF="http://www.aflyingstart.net/addons/">http://www.aflyingstart.net/addons/</A>
<p>Enquiries regarding Shop@ssistant Classic training :
<br>Call 01256 880770
<p>Rodney Myers
<br>Based in Oxford, England
<br>Technical Director, Shop@ssistant eCommerce Solutions
<br>&nbsp;</html>