By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,738 Members | 2,076 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,738 IT Pros & Developers. It's quick & easy.

Determine the height and width of a frame.

dmjpro
100+
P: 2,476
Suppose i have a HTML file like this....
Expand|Select|Wrap|Line Numbers
  1. <frameset rows="10%,*">
  2. <frame name="frame1" src="page1"/>
  3. <frame name="frame2" src="page2"/>
  4. </frameset>
  5.  
Now my page1 is like this ..
Expand|Select|Wrap|Line Numbers
  1. <frameset cols="50%,*">
  2. <frame name="frame1" src="page3"/>
  3. <frame name="frame2" src="page4"/>
  4. </frameset>
  5.  
Now my page2 is like this ...
Expand|Select|Wrap|Line Numbers
  1. <frameset cols="50%,*">
  2. <frame name="frame1" src="page5"/>
  3. <frame name="frame2" src="page6"/>
  4. </frameset>
  5.  
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 .... :)
Sep 26 '08 #1
Share this Question
Share on Google+
9 Replies


dmjpro
100+
P: 2,476
I found the solution and managed the full fill the target.
Basically it is possible with window.innerHeight and window.innerWidth.
Sep 26 '08 #2

acoder
Expert Mod 15k+
P: 16,027
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.
Sep 26 '08 #3

gits
Expert Mod 5K+
P: 5,328
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
Sep 26 '08 #4

dmjpro
100+
P: 2,476
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.height and width only gives the width and height of top screen.... :(
Sep 26 '08 #5

dmjpro
100+
P: 2,476
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 ....

Expand|Select|Wrap|Line Numbers
  1. <frameset cols="50%,*">
  2. <frame src="page1"/>
  3. <frame src="page2"/>
  4. </frameset>
  5.  
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.clientWidth 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 ?
Sep 26 '08 #6

dmjpro
100+
P: 2,476
I am still having the problem .... Without testing i told that i found the perfect solution.
See ......
I have the starting page ....

Expand|Select|Wrap|Line Numbers
  1. <frameset rows="50%,*">
  2. <frame src="test.html"/>
  3. <frame src="another_frame.html"/>
  4. </frameset>
  5.  
Now another_frame.html is ..

Expand|Select|Wrap|Line Numbers
  1. <frameset cols="50%,*">
  2. <frame src="test.html"/>
  3. <frame src="main_page.html"/>
  4.  
Now main_page.html is ...

Expand|Select|Wrap|Line Numbers
  1. <head>
  2. <script type="text/javascript">
  3. function test(){
  4.     alert(parent.document.body.clientWidth);
  5. }
  6. </script>
  7. </head>
  8.  
  9. <body onload=test()></body>
  10.  
It still getting the same result .... i want to have how much screen area acquired by the another_frame.html 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!
Sep 26 '08 #7

gits
Expert Mod 5K+
P: 5,328
did you try the getComputedStyle()/currentStyle solution that you may find in the link i already showed you?
Sep 26 '08 #8

dmjpro
100+
P: 2,476
did you try the getComputedStyle()/currentStyle solution that you may find in the link i already showed you?
Gits i could not figure out anything..please will you help me to do ....
Above I mentioned my problem ..... ;)
Thanks!
Sep 27 '08 #9

dmjpro
100+
P: 2,476
did you try the getComputedStyle()/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.offsetWidth/Height

Thanks all ... !!!!
Sep 27 '08 #10

Post your reply

Sign in to post your reply or Sign up for a free account.