Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Window Resize

Reply
Thread Tools

Window Resize

 
 
Peter
Guest
Posts: n/a
 
      05-14-2005
I would like to automatically resize a window to its content. I was thinking
of using an outer table to detect the size of my content, then use
window.resizeTo( ).

The problem is I'm not sure how I can determine the size of what I think is
referred to as the 'chrome' - the window borders, toolbars, etc.

Is there a way to determine the height and width of the chrome so that I can
supply the correct parameters to the resizeTo method?


 
Reply With Quote
 
 
 
 
Richard Cornford
Guest
Posts: n/a
 
      05-14-2005
Peter wrote:
> I would like to automatically resize a window to its
> content. I was thinking of using an outer table to
> detect the size of my content, then use window.resizeTo( ).
>
> The problem is I'm not sure how I can determine the size
> of what I think is referred to as the 'chrome' - the
> window borders, toolbars, etc.
>
> Is there a way to determine the height and width of the
> chrome so that I can supply the correct parameters to the
> resizeTo method?


The dimension of the top and left chrome can be determined on browsers
that expose the screen offsets of their window to scripting, given a
mouse input event. By reading the mouse's screen co-ordinates, and its
viewport co-ordinates and using the difference to give the screen
co-ordinates of the viewport. The difference between the screen
co-ordinates of the window and the screen co-ordinates of the viewport
give the dimensions of the chrome at the top of the window and the
chrome to the left.

The screen co-ordinates of the window are not universally available in
browser object models (and in framesets the values don't necessarily
have the same meaning).

The other proposed possible strategy for determining the chrome
dimensions in total is to measure the viewport dimensions, re-size the
window to the original viewport dimensions and then re-measure the
viewport dimensions. The difference being the total dimensions of the
chrome (left+right and top+bottom), assuming that the second set of
viewport dimensions didn't drop to zero, which would invalidate the
results.

Obviously re-sizing the window a couple of times is not going to look
that good to the user. And these days the ability to re-size a browser
window is subject to user veto, so it will often not work at all.

A better approach is probably to adopt a fluid HTML design that adapts
to whatever size the user's window happens to be.

Richard.


 
Reply With Quote
 
 
 
 
Peter
Guest
Posts: n/a
 
      05-15-2005
Thank you Richard for the thorough response. That helps a lot. As far as
user experience goes, I agree with your opinion, but in this case, it is for
a private web application and the need is for the browser to conform to the
size of the content. Since I have only one browser to target, this should be
doable.

Thanks again,
Peter

Richard Cornford wrote:
> Peter wrote:
>> I would like to automatically resize a window to its
>> content. I was thinking of using an outer table to
>> detect the size of my content, then use window.resizeTo( ).
>>
>> The problem is I'm not sure how I can determine the size
>> of what I think is referred to as the 'chrome' - the
>> window borders, toolbars, etc.
>>
>> Is there a way to determine the height and width of the
>> chrome so that I can supply the correct parameters to the
>> resizeTo method?

>
> The dimension of the top and left chrome can be determined on browsers
> that expose the screen offsets of their window to scripting, given a
> mouse input event. By reading the mouse's screen co-ordinates, and its
> viewport co-ordinates and using the difference to give the screen
> co-ordinates of the viewport. The difference between the screen
> co-ordinates of the window and the screen co-ordinates of the viewport
> give the dimensions of the chrome at the top of the window and the
> chrome to the left.
>
> The screen co-ordinates of the window are not universally available in
> browser object models (and in framesets the values don't necessarily
> have the same meaning).
>
> The other proposed possible strategy for determining the chrome
> dimensions in total is to measure the viewport dimensions, re-size the
> window to the original viewport dimensions and then re-measure the
> viewport dimensions. The difference being the total dimensions of the
> chrome (left+right and top+bottom), assuming that the second set of
> viewport dimensions didn't drop to zero, which would invalidate the
> results.
>
> Obviously re-sizing the window a couple of times is not going to look
> that good to the user. And these days the ability to re-size a browser
> window is subject to user veto, so it will often not work at all.
>
> A better approach is probably to adopt a fluid HTML design that adapts
> to whatever size the user's window happens to be.
>
> Richard.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to resize all images sizes and coordinates of the images on resize browser rams.kakara@gmail.com ASP General 2 02-13-2005 09:03 AM
Resize window not working in IE5.0 RJN ASP .Net 0 09-30-2004 02:52 PM
Resize window not working in IE5.0 RJN ASP .Net 0 09-29-2004 04:15 PM
resize window refreshes screen DC Gringo ASP .Net 0 04-05-2004 11:14 PM
Window Resize in IE 5.0? al ASP .Net 3 04-05-2004 02:27 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57