Print Page | Close Window

Dynamically Resize 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=3684
Printed Date: 29 March 2026 at 6:02am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Dynamically Resize Window
Posted By: Gary
Subject: Dynamically Resize Window
Date Posted: 20 June 2003 at 3:33am

I have a web based app which has a db search facility. When activated, the search results are displayed in a new window. Things is, sometimes the window is not wide enough (I dont want scrollbars).

Is it possible in Javascript to dynamically resize the window to the required width depending upon the width of the table data displayed?

Thx




Replies:
Posted By: Bluefrog
Date Posted: 25 June 2003 at 8:44am
No. You can't access any property that will tell you the width of a table. You're better off scripting it with ASP or something.


Posted By: b_bonnett
Date Posted: 27 June 2003 at 5:42am

An idea - I'm fairly sure you can use Javascript to find the width of a <div> element - so you could enclose the output in <div>...</div> tags and work out the width of the page that way...

Blair



-------------
Webmaster, http://www.planegallery.net/ - The Plane Gallery
Greetings From Christchurch


Posted By: Gary
Date Posted: 27 June 2003 at 7:54am

Afraid that wont work....

I dont think there is a 'width' attribute with <DIV>'s. Ok, you can set it within the tag itself, but it has no effect whatsoever and JS will tell you what you already know (ie the width that you set within the tag).

 



Posted By: Bluefrog
Date Posted: 29 June 2003 at 7:54pm

Ok - I think this is the answer -

http://www.smpte.com.au/event.asp?pid=302 - http://www.smpte.com.au/event.asp?pid=302

Check out their code to do it. I think that's what you're looking for, sort of... but I don't know if it's totally dynamic. I just dont' have time to sort through the code right now.

Hope it helps anyways.



Posted By: Gary
Date Posted: 30 June 2003 at 2:40am

Looking at the code, it seems that this is not a dynamic resize. The resizeTo(810,600) is hard coded and the site is possibly using frames or css for the layout.

What I need to do is resize the window width to accomodate the entire contents with no wrapping and no horizontal scrolling. Because of the dynamic nature of the content, the document could be 400 pixels wide, 500, 510, etc.

This is starting to look to be completely impossible. Yes, you can set a table to utilize the full width of the browser (ie 100%), but I need to then be able to detect what the actual width is in pixels so that I can then issue a javascript resizeTo.



Posted By: Bluefrog
Date Posted: 01 July 2003 at 7:57am

I guess it's time to pull out the ol' calculator...

Determine the number of characters, the font size translated into pixels, etc... then you can do it...

If you use a monospace font like Courier, the math for this is much simpler...

I.E. Nightmare on your street...

I've thought of that one before - I gave up... Fonts change across browsers too...  

 



Posted By: Gary
Date Posted: 01 July 2003 at 8:11am

I didn't think it would be possible, but hey, no harm in asking.

You never know, there may be someone out there that has done it somehow.

Considering all the other stuff that you can do, I'm surprised that something that seems relatively simple like ascertaining the width would be a piece of cake.



Posted By: Wulf
Date Posted: 22 July 2003 at 3:47pm

Has anyone tried using an image?

I was thinking of trying a transparent gif set to a width of 100% and seeing how many pixels wide it is.

Has anyone tried this?



Posted By: Wulf
Date Posted: 22 July 2003 at 5:06pm

This works:

http://zendocs.phpzen.net/bin/view/Know/JavascriptSizeToContent - http://zendocs.phpzen.net/bin/view/Know/JavascriptSizeToContent




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