| Author |
Topic Search Topic Options
|
Gary
Senior Member
Joined: 20 March 2002
Location: United Kingdom
Status: Offline
Points: 326
|
Topic: Dynamically Resize Window 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
|
 |
Bluefrog
Senior Member
Joined: 23 October 2002
Location: Korea, South
Status: Offline
Points: 1701
|
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.
|
 |
b_bonnett
Mod Builder Group
Joined: 16 April 2003
Location: New Zealand
Status: Offline
Points: 275
|
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
|
|
|
 |
Gary
Senior Member
Joined: 20 March 2002
Location: United Kingdom
Status: Offline
Points: 326
|
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).
|
 |
Bluefrog
Senior Member
Joined: 23 October 2002
Location: Korea, South
Status: Offline
Points: 1701
|
Posted: 29 June 2003 at 7:54pm |
Ok - I think this is the answer -
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.
|
 |
Gary
Senior Member
Joined: 20 March 2002
Location: United Kingdom
Status: Offline
Points: 326
|
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.
|
 |
Bluefrog
Senior Member
Joined: 23 October 2002
Location: Korea, South
Status: Offline
Points: 1701
|
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...
|
 |
Gary
Senior Member
Joined: 20 March 2002
Location: United Kingdom
Status: Offline
Points: 326
|
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.
|
 |