SuperWasp

SuperWasp

Productivity tips, reviews, tools, software and gadgets.

 
HOWTO: Resize popup window to fit image
Advertisement:
The following code is my optimized version of a popup script you can find all over the internet (and for which I don't take credit). It mainly fixes two issues: it now better separates between IE, Netscape/Mozilla/Firefox and Opera, and it also fixes a problem with IE6 that behaves strangely when using body.clientWidth and body.clientHeight.


<html>
<head>
<title>AutoSize Browser To Image</title>
<script language='javascript'>
var arrTemp=self.location.href.split("?");
var picUrl = (arrTemp.length>0)?arrTemp[1]:"";
var NS = (navigator.appName=="Netscape")?true:false;
var NS = ((!document.all)||window.opera)?true:false;
function AutoSize() {
var iWidth = (NS)?window.innerWidth:document.documentElement.clientWidth;
var iHeight = (NS)?window.innerHeight:document.documentElement.clientHeight;
iWidth = document.images[0].width - iWidth;
iHeight = document.images[0].height - iHeight;
window.resizeBy(iWidth, iHeight);
self.focus();
};
</script>
</head>
<body bgcolor="#000000" onload="AutoSize();" style="margin:0;padding:0;">
<script language='javascript'>
document.write( "<img src='" + picUrl + "' border='0'>" );
</script>
</body>
</html>

  Posted by oVan on Thursday, September 15, 2005 | PermaLink | 1 comments
« SuperWasp start page