Not real sure what you're wanting the window to autofit to, but I use it to autofit pictures. Here's the code I use.
(This isn't my code, I just found it. It didn't have any dev. info, so don't get mad that I didn't include it)
//Function to open picture in new windows
function OpenImage(img){
foto1= new Image();
foto1.src=(img);
Controlla(img);
}
function Controlla(img){
if((foto1.width!=0)&&(foto1.height!=0)){
viewFoto(img);
}
else{
funzione="Controlla('"+img+"')";
intervallo=setTimeout(funzione,20);
}
}
function viewFoto(img){
largh=foto1.width+20;
altez=foto1.height+20;
stringa="width="+largh+",height="+altez;
finestra=window.open("/includes/showpicture.asp?img="+img,"",stringa);
}
|
I call it just like any other javascript:
<a href="javascript:OpenImage('whatever you want in here')">
|
And here's the code for the page to display pictures.
<html>
<!--#include virtual="/includes/skin_file.asp" -->
<body onClick="self.close()" bgcolor="<% = strBgColor %>"
topmargin="10" bottommargin="10" leftmargin="10" rightmargin="10">
<%
ShowPic = Request.Querystring("img")
ShowPic = Replace(ShowPic, " ", "%20")
Response.Write "<img src=" & ShowPic & " border='0'
style='border: 1px solid rgb(128,128,128);' alt='Click Anywhere To
Close Window'><br />"
%>
</body>
</html>
|
This works really well for me. Hopefully it helps you out.