2

Possible Duplicate:
How to auto-size an iFrame?

Here is the thing, i have a menu with lots of links, these links have an iframe as target.

The pages that load in the iframe have multiple heights, so i wanted to get the height of the page loaded in the iframe and apply it to the iframe.

I tried some codes with jquery and pure javascript around the net but none worked.

What should i do?

Community
  • 1
  • 1
marcelosan
  • 41
  • 1
  • 6

1 Answers1

0

If page is on same domain then you can calculate height of document of iframe and based on height you can set height of iframe.

$("iframe").load(
          function(){
          $(this).height($(this).contents().height() );
          }
       );
Anoop
  • 23,044
  • 10
  • 62
  • 76
  • It's on the same domain, but how i can get the heigth of the page loaded on the iframe to change automat the height of the iframe? I need every page loaded inside the iframe adjusted with it's content – marcelosan Nov 07 '12 at 18:19
  • @user1806962 See my answer . it will automatically set the height on page load – Anoop Nov 07 '12 at 18:21
  • Thank you @Sushil , i made a mistake in the first try, but now it's working fine. I got confused by all the codes i've tried so far, but now you really helped me. Thank you. – marcelosan Nov 07 '12 at 18:29
  • You should share your your solution here so that other can get help from that. – Anoop Nov 07 '12 at 18:30