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

how to find out the size(height and width) of frame in iframe

P: 7
hello,

I want to find out the height and width of right frame in iframe that is included in left frame.

main.html
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <frameset cols="15%, *" id="fs1">
  3. <frame src="left.html" name="left" frameborder="1" id=leftId >
  4. <frame src="right.html" name="right" frameborder="1" id=rightId>
  5. </frameset>
  6. </html>
suppose in left frame i have included a iframe and in that iframe code i want to find out the size of right frame.

left.html
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. </head>
  4. <body>
  5. <iframe src ="iframe_test.html" width="100%" height="300px">
  6. </iframe>
  7. </body>
  8. </html>
right.html page could be any html page.

iframe_test.html
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script>
  4. // Here i want to find out the height and width of right frame 
  5. </script>
  6. </head>
  7. </html>
Jan 5 '09 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 164
try this:

Expand|Select|Wrap|Line Numbers
  1. var frameR = window.frames[1].contentDocument;
  2.  
  3. var frameR_w = frameR.width ? frameR.width : frameR.documentElement.offsetWidth;
  4.  
  5. var frameR_h = frameR.height ? frameR.height : frameR.documentElement.offsetHeight;
  6.  
Jan 5 '09 #2

Post your reply

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