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.
|