Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to wrap a window to fit the contents

Status
Not open for further replies.

toolkit

Programmer
Aug 5, 2001
771
GB
Hi there.

I have a bit of HTML/JavaScript that opens a window, and generates a form dynamically using CGI:

Code:
<input
  type=button
  value=dynamic
  onclick=&quot;window.open('/cgi/dynamicform.pl?var1=me&var2=myself&var3=i', 'dynamic', 'width=300,height=300,resizable')&quot;
>

The cgi script creates a dynamic form, that will require a different display area depending on the fonts used by the browser, and the variables passed in.

My question is this: What is the best way to dynamically wrap the window to its contents? Perhaps some onLoad code, that figures out the dimensions? Any browser neutral code examples would be most appreciated :)

Thanks, NEIL
 
Hello NEIL,
I *think* what you are looking for is the method &quot;window.SizetoContent(). Below is some specs I had on it but I've never used the technic myself.
-----------------------------------------------------------
Description
sizeToContent() is the window element's method for opening reflowing an open window.
Syntax
window.sizeToContent()
Example
window.sizeToContent()
Notes
This reflows the window's content, and wraps the window around those contents. It functions even on fixed size windows (that is, windows with the &quot;resizable&quot; flag turned off.) This function's intended use is with intrinsically sized windows (those which are designed to wrap themselves to fit their content) after changing that content, presumably during the execution of an onload handler.
-----------------------------------------------------------
Check references of this method for possible examples.
Good luck,
- Omicron -

 
Omicron

When searching for information on this function, tt appears it is currently for the Mozilla XUL Intreface only. Are you sure it works for normal IE and NS?

Cheers, NEIL
 
Anyone have any other ideas on this one?

Thanks, NEIL
 
Looks good. Will use if I have any images. Unfortunately the page I was trying to load was a table. I may resort to using an (in)visible div instead of a separate window.

Thanks anyways, Neil :)
 
Could try using the offsetWidth of the element you want to wrap, and resize the window. This is O.K., but may result in some 'flashing' as it reshapes the window.

I think divs look way better then new windows anyway.

;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top