Print Page | Close Window

Javascript: auto fit window?

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Web Design Discussion
Forum Description: Discussion on web design and development subjects.
URL: https://forums.webwiz.net/forum_posts.asp?TID=16366
Printed Date: 28 March 2026 at 11:23pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Javascript: auto fit window?
Posted By: pilot99
Subject: Javascript: auto fit window?
Date Posted: 28 August 2005 at 2:52pm
i know how to change the window size through javascript but i was wondering if it possible to make it auto fit so if something expands so does the window.



Replies:
Posted By: pilot99
Date Posted: 04 September 2005 at 9:46pm
someone please this is important.

-------------
http://www.globaltornado.com">


Posted By: ub3rl337ch3ch
Date Posted: 06 September 2005 at 6:57pm

i'm pretty sure you can use javascript to check the value of the width/height properties of objects. set up a function that checks the value of the width and the resizes the window appropriately.

i have no idea about the exact syntax,  but there's one way you could do it...


Posted By: skwfalcon16
Date Posted: 11 September 2005 at 4:59pm
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.


-------------
http://www.spreadfirefox.com/?q=affiliates&id=179077&t=82">


Posted By: pilot99
Date Posted: 12 September 2005 at 8:28pm
yah ive already stumbled upon that but its not an image.

-------------
http://www.globaltornado.com">



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net