Get Frame Size

Discussion in 'Javascript' started by Olumide -, Oct 27, 2003.

  1. Olumide -

    Olumide - Guest

    How can javascript be used to get the size of a Frame in a document.

    Thanks

    - Olumide


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Olumide -, Oct 27, 2003
    #1
    1. Advertising

  2. Olumide -

    Fred Snider Guest

    Olumide - <> wrote in message news:<3f9daac8$0$201$>...
    > How can javascript be used to get the size of a Frame in a document.
    >
    > Thanks
    >
    > - Olumide
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!



    Here is the code I use. wxsize is the width of the third frame on my
    screen, and
    wysize is the height of the third frame. The [2] refers to the order
    in which the frames were created with the FRAMESET. First one is [0].
    This is browser dependent! my variable isNav is true if the browser is
    netscape, false if it is IE or Opera

    //- browser dependent- no way around it...
    function getsize(){
    if (isNav){
    // frame dimensions in netscape
    wysize= (parent.window.frames[2].innerHeight)
    wxsize= (parent.window.frames[2].innerWidth)
    }else{
    // frame dimensions in IE or Opera
    wysize= (top.frames[2].document.body.clientHeight)
    wxsize= (top.frames[2].document.body.clientWidth)
    }
    }

    Note you have to wait until all frames are loaded before you call
    this, otherwise you get garbage. I use a call to this routine in the
    last FRAMESET document to get loaded using the body command:: <body
    onload="getsize()">

    Hope this helps.

    Fred
     
    Fred Snider, Oct 28, 2003
    #2
    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. Søren M. Olesen
    Replies:
    0
    Views:
    578
    Søren M. Olesen
    Nov 13, 2003
  2. Microsoft
    Replies:
    3
    Views:
    698
    Hugo Wetterberg
    Oct 4, 2004
  3. ABC
    Replies:
    0
    Views:
    595
  4. Jason Cavett

    Preferred Size, Minimum Size, Size

    Jason Cavett, May 23, 2008, in forum: Java
    Replies:
    5
    Views:
    12,582
    Michael Jung
    May 25, 2008
  5. Fokke Nauta
    Replies:
    3
    Views:
    940
    Fokke Nauta
    Apr 29, 2009
Loading...

Share This Page