Window Resize

Discussion in 'Javascript' started by Peter, May 14, 2005.

  1. Peter

    Peter Guest

    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?
     
    Peter, May 14, 2005
    #1
    1. Advertising

  2. 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.
     
    Richard Cornford, May 15, 2005
    #2
    1. Advertising

  3. Peter

    Peter Guest

    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.
     
    Peter, May 15, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. al

    Window Resize in IE 5.0?

    al, Apr 2, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    594
    Jim Cheshire [MSFT]
    Apr 5, 2004
  2. DC Gringo

    resize window refreshes screen

    DC Gringo, Apr 6, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    377
    DC Gringo
    Apr 6, 2004
  3. RJN
    Replies:
    0
    Views:
    459
  4. RJN
    Replies:
    0
    Views:
    450
  5. Replies:
    2
    Views:
    1,282
    Adrienne
    Feb 13, 2005
Loading...

Share This Page