

<?xml version="1.0" encoding="UTF-8"?>
	<rss version="2.0"
		xmlns:content="http://purl.org/rss/1.0/modules/content/"
		xmlns:wfw="http://wellformedweb.org/CommentAPI/"
		xmlns:dc="http://purl.org/dc/elements/1.1/"
		xmlns:atom="http://www.w3.org/2005/Atom"

			>

	<channel>
		<title>LexiConn News  &#187;  Topic: Creating Perfectly Sized Popups</title>
		<atom:link href="https://support.lexiconn.com/news/forums/topic/creating-perfectly-sized-popups/feed" rel="self" type="application/rss+xml" />
		<link>https://support.lexiconn.com/news/forums/topic/creating-perfectly-sized-popups/feed</link>
		<description></description>
		<pubDate>Mon, 06 Apr 2026 05:01:10 +0000</pubDate>
		<generator>http://bbpress.org/?v=2.5.3-5249</generator>
		<language>en-US</language>

		
														
					
				<item>
					<guid>https://support.lexiconn.com/news/forums/topic/creating-perfectly-sized-popups/#post-48540</guid>
					<title><![CDATA[Creating Perfectly Sized Popups]]></title>
					<link>https://support.lexiconn.com/news/forums/topic/creating-perfectly-sized-popups/#post-48540</link>
					<pubDate>Thu, 02 Nov 2006 19:52:43 +0000</pubDate>
					<dc:creator>Anonymous</dc:creator>

					<description>
						<![CDATA[
						<p>Creating popups on your website that are the exact size of the image (or text) that you are opening up can be extremely useful as they look very professional and are an optimal use of space. You can resize a popup to perfectly fit an image, even if you do not know how big that image is. The following website is an excellent resource for creating &#8216;perfect popups&#8217;:</p>
<p><a href="http://www.howtocreate.co.uk/perfectPopups.html" rel="nofollow">http://www.howtocreate.co.uk/perfectPopups.html</a></p>
<p>The text following this paragraph provides example code for creating a perfectly sized popup. The code can be inserted into a webpage directly, or called via a .js call. Since the size of the image is unknown, the script is inserted into the popup, which waits until the image has loaded before resizing it to fit &#8220;perfectly&#8221;. The script even falls back to use regular windows if popups are blocked or if JavaScript is disabled.</p>
<p>&nbsp;</p>
<pre>&lt;script type="text/javascript" language="JavaScript"&gt; 
 //really not important (the first two should be small for Opera's sake) 
 PositionX = 10; 
 PositionY = 10; 
 defaultWidth  = 600; 
 defaultHeight = 400; 
 
 //kinda important 
 var AutoClose = true; 
 
 //don't touch 
 function popImage(imageURL,imageTitle){ 
   var imgWin = window.open('','_blank','scrollbars=no,resizable=1,width='+defaultWidth+',height='+ 
 defaultHeight+',left='+PositionX+',top='+PositionY); 
   if( !imgWin ) { return true; } //popup blockers should not cause errors 
   imgWin.document.write('&lt;html&gt;&lt;head&gt;&lt;title&gt;'+imageTitle+'&lt;\/title&gt;&lt;script type="text\/javascript"&gt;\n'+ 
     'function resizeWinTo() {\n'+ 
     'if( !document.images.length ) { document.images[0] = document.layers[0].images[0]; }'+ 
     'var oH = document.images[0].height, oW = document.images[0].width;\n'+ 
     'if( !oH || window.doneAlready ) { return; }\n'+ //in case images are disabled 
     'window.doneAlready = true;\n'+ //for Safari and Opera 
     'var x = window; x.resizeTo( oW + 200, oH + 200 );\n'+ 
     'var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;\n'+ 
     'if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }\n'+ 
     'else if( d &amp;&amp; d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }\n'+ 
     'else if( b &amp;&amp; b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }\n'+ 
     'if( window.opera &amp;&amp; !document.childNodes ) { myW += 16; }\n'+ 
     'x.resizeTo( oW = oW + ( ( oW + 200 ) - myW ), oH = oH + ( (oH + 200 ) - myH ) );\n'+ 
     'var scW = screen.availWidth ? screen.availWidth : screen.width;\n'+ 
     'var scH = screen.availHeight ? screen.availHeight : screen.height;\n'+ 
     'if( !window.opera ) { x.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2)); }\n'+ 
     '}\n'+ 
     '&lt;\/script&gt;'+ 
     '&lt;\/head&gt;&lt;body onload="resizeWinTo();"'+(AutoClose?' onblur="self.close();"':'')+'&gt;'+ 
     (document.layers?('&lt;layer left="0" top="0"&gt;'):('&lt;div style="position:absolute;left:0px;top:0px;display:table;"&gt;'))+ 
     '&lt;img src='+imageURL+' alt="Loading image ..." title="" onload="resizeWinTo();"&gt;'+ 
     (document.layers?'&lt;\/layer&gt;':'&lt;\/div&gt;')+'&lt;\/body&gt;&lt;\/html&gt;'); 
   imgWin.document.close(); 
   if( imgWin.focus ) { imgWin.focus(); } 
   return false; 
 } 
 &lt;/script&gt;</pre>
<p>&nbsp;</p>
<p>The script can be called via the following:</p>
<p>&nbsp;</p>
<pre>&lt;a href="FILENAME.jpg" onclick="return popImage(this.href,'TITLE OF THE POPUP');"&gt;CLICK_HERE_FOR_POPUP&lt;/a&gt;</pre>
<p>&nbsp;</p>
						]]>
					</description>

					
					
				</item>

					
		
	</channel>
	</rss>

