Determine the height and width of a frame.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    Determine the height and width of a frame.

    Suppose i have a HTML file like this....
    Code:
    <frameset rows="10%,*">
    <frame name="frame1" src="page1"/>
    <frame name="frame2" src="page2"/>
    </frameset>
    Now my page1 is like this ..
    Code:
    <frameset cols="50%,*">
    <frame name="frame1" src="page3"/>
    <frame name="frame2" src="page4"/>
    </frameset>
    Now my page2 is like this ...
    Code:
    <frameset cols="50%,*">
    <frame name="frame1" src="page5"/>
    <frame name="frame2" src="page6"/>
    </frameset>
    Now page3,page4 contain the view part .......
    If i want to determine the height and width of any frame ..then how could i get that?
    It is possible what i think ..that is by back calculation ..means using the percentage value of each frame and having the top window width and height, we can do it ....
    But is there any direct API by which i can get the height and width easily of any frame ?
    Any help would be appreciated .... :)
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    I found the solution and managed the full fill the target.
    Basically it is possible with window.innerHei ght and window.innerWid th.

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      I don't usually (ever?) work with frames, but this link may help.

      Edit: didn't realise you'd already posted. I'm not sure if innerHeight/Width always gives reliable results. You may want to test just in case.

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        hi ...

        you may ask an element for its current or computed style ... have a look here at the section where the 'getStyle()' method is described ...

        kind regards

        Comment

        • dmjpro
          Top Contributor
          • Jan 2007
          • 2476

          #5
          Gits and Acoder!
          Basically my solution works with Mozilla only ...trying to find out the IE compatibility. What i trying to do i m setting the cols or rows according to the current resolution so that it shows the appropriate result at each screen resolution. That's why i need to have the window height and width ..i mean the screen width and height not the actual one .... ;)
          now ..... window.screen.h eight and width only gives the width and height of top screen.... :(

          Comment

          • dmjpro
            Top Contributor
            • Jan 2007
            • 2476

            #6
            Originally posted by acoder
            I don't usually (ever?) work with frames, but this link may help.

            Edit: didn't realise you'd already posted. I'm not sure if innerHeight/Width always gives reliable results. You may want to test just in case.

            Acoder I looked at your prescribed link there i found my solution ..basically i was on the right track but i did a little bit wrong .... ;)
            Actually i am having a main page contains two frames .....like this ....

            Code:
            <frameset cols="50%,*">
            <frame src="page1"/>
            <frame src="page2"/>
            </frameset>
            Now page1 and page2 contains some view part .... having the window reference of page1 or page2 what i did earlier ...i was retrieving the screen height and screen width using window.ducument .body.clientWid th and clientHeight. But it shown me the actual height and width what window acquired .... But what i needed to do .... i should have used .. parent.document .clientWidth or clientHeight

            I think it fulfills my target ..... what you say ?
            Would there any be help for me ?

            Comment

            • dmjpro
              Top Contributor
              • Jan 2007
              • 2476

              #7
              I am still having the problem .... Without testing i told that i found the perfect solution.
              See ......
              I have the starting page ....

              Code:
              <frameset rows="50%,*">
              <frame src="test.html"/>
              <frame src="another_frame.html"/>
              </frameset>
              Now another_frame.h tml is ..

              Code:
              <frameset cols="50%,*">
              <frame src="test.html"/>
              <frame src="main_page.html"/>
              Now main_page.html is ...

              Code:
              <head>
              <script type="text/javascript">
              function test(){
              	alert(parent.document.body.clientWidth);
              }
              </script>
              </head>
              
              <body onload=test()></body>
              It still getting the same result .... i want to have how much screen area acquired by the another_frame.h tml page. It is supposed to result the half of the total width of the top screen..... Could you help me to solve this problem.

              Thanks!

              Comment

              • gits
                Recognized Expert Moderator Expert
                • May 2007
                • 5390

                #8
                did you try the getComputedStyl e()/currentStyle solution that you may find in the link i already showed you?

                Comment

                • dmjpro
                  Top Contributor
                  • Jan 2007
                  • 2476

                  #9
                  Originally posted by gits
                  did you try the getComputedStyl e()/currentStyle solution that you may find in the link i already showed you?
                  Gits i could not figure out anything..pleas e will you help me to do ....
                  Above I mentioned my problem ..... ;)
                  Thanks!

                  Comment

                  • dmjpro
                    Top Contributor
                    • Jan 2007
                    • 2476

                    #10
                    Originally posted by gits
                    did you try the getComputedStyl e()/currentStyle solution that you may find in the link i already showed you?

                    Sorry Acoder and Gits!
                    Finally i tested the code and thought a lot before posting ...
                    I found the solution ......
                    I am getting the desired output using parent.document .body.offsetWid th/Height

                    Thanks all ... !!!!

                    Comment

                    Working...