SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Addict
    Join Date
    Dec 2001
    Location
    Market Harborough, UK
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Detecting a window resize

    Hi,

    I hope this is a straightforward question.....!

    Can anyone tell me how I can detect when a window is resized? It seems that onresize only applies to frames (at least that's what my docs say!)

    I need to re-scale some stuff if the user resizes the browser window.

    TIA
    Paul Simpson, BSc, MCNI, MCNE

  2. #2
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There is no event in the DOM that refers to this.
    Anything you do find would be just using proprietary Microsoft standards and I would recommend against it.

    I have to be honest - your question leads to the often seen parody here: Q: "What's the best way to stab myself in the foot?"
    So we can either help you stab yourself in the foot... and believe me, we can get it done real well ;o), or we can assess why you think this should be done.

    So: Why do you think that you need to rescale stuff ?
    Personally I'm one of the people that prefers to abuse the intended function of tables, rather than using css.
    I'd make a layout so that it scales naturally with the browser by using tables.

    Tell us your thoughts.

    G
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  3. #3
    SitePoint Addict
    Join Date
    Dec 2001
    Location
    Market Harborough, UK
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm curious to know how this would be stabbing myself in the foot?

    I have a site which is for internal use only. It fronts our in-house database. (I can't therefore give you a link to have a look.)

    Anyway, the page is made up of various regions. Along the top is a title bar which is fixed size. Down the left is a menu system which is fixed size. Both of these are created using <DIV>s. The main part of the screen (bottom right) is also a <DIV> which is resized when the page loads to take up the remainder of the browser window. This part has scrollbars if required.

    Currenly, if a user opens the system in a fairly small window and then maximises the screen, they end up with a small details section with scrollbars in the middle of the screen and a lot of blank space. This is, of course, until they refresh the screen when it re-draws itself to the correct size.

    I'd like to trap the window resize so that I can alter the dimensions of the <DIV> as appropriate. I don't particularly care if it only works with one browser since the whole site is I.E. specific. As it's internal use only, we control the desktop and only use IE here.

    Any help appreciated.
    Paul Simpson, BSc, MCNI, MCNE

  4. #4
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Open the page and make it unrizeable... You can do that, IIRC.
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  5. #5
    SitePoint Addict
    Join Date
    Dec 2001
    Location
    Market Harborough, UK
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can, but don't want to! I want the users to be able to resize the window and have the content scale to match, as you'd expect from a browser. I still fail to see how this is shooting myself in the foot, unless you mean that I'm tying myself to a specific browser - in which case, as I've explained, in this case that doesn't matter.

    You did say there was an I.E. specific solution - care to elaborate?

    Thanks
    Paul Simpson, BSc, MCNI, MCNE

  6. #6
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    document.body.onresize= resizeFunction;

    Try that.
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  7. #7
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure, but you could probably stick an iframe where your current "scrolling" div is. Use tables instead of divs for the rest and give the iframe a 100% width and height inside it's table. I've not tried this, but I think it might leave it so you have your scrolling area still, and change size with the screen...
    Does that sound like it's worth a shot for you ?
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  8. #8
    SitePoint Addict
    Join Date
    Dec 2001
    Location
    Market Harborough, UK
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'll try the first option.

    Grrrr. The second one - I've just spent ages changing the whole site to be <DIV> based and using a CSS away from being all a big table. It's certainly snappier now, so I'd hate to have to revert....

    Thanks for the suggestions :-)
    Paul Simpson, BSc, MCNI, MCNE

  9. #9
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have a look at the way the resize event is handled in the X Library. For all browsers but Opera7 and IE4+, the event is simulated. The scroll event is handled in the same way.

    But if you're IE-only on your intranet, then Flawless_koder has already given the correct code.

    Edit:

    btw, go to the downloads section of my site to get X
    Last edited by MikeFoster; Oct 10, 2003 at 07:41.

  10. #10
    SitePoint Addict
    Join Date
    Dec 2001
    Location
    Market Harborough, UK
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wooohoooo!

    It worked, thanks guys!

    It was even better than I'd hoped - it resizes as you drag, rather than waiting until the resize is complete!

    Cool.
    Paul Simpson, BSc, MCNI, MCNE

  11. #11
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've noticed that too - maybe just on NT/W2K. It would be interesting to know what OS you're using.

  12. #12
    SitePoint Addict
    Join Date
    Dec 2001
    Location
    Market Harborough, UK
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm using XP and IE6

    We do have W98 and W2K around the place, I'll let you know which does what once I've had the chance to check.
    Paul Simpson, BSc, MCNI, MCNE

  13. #13
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks

    XP Pro is in the same OS family as NT/W2K, so that makes sense.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •