0

Is there any method available to adjust the height of an iframe (which loads an external site) dynamically ?

OR

is there any way to check whether if the iframe has a scroll-bar present ?

raki
  • 2,253
  • 8
  • 33
  • 42
  • 2
    I believe this http://stackoverflow.com/questions/819416/adjust-width-height-of-iframe-to-fit-with-content-in-it is what you are looking for – Joshua Apr 19 '13 at 12:37
  • Yes , but nothing is working for me . I am trying to load the document from an external site :( – raki Apr 19 '13 at 12:59
  • Since you can not access anything when the iframe is from another domain, this will only work if the remote site is “helping” you – like Facebook does for canvas/page tab apps f.e., they do some cross-domain communication so that the iframed page sends its own height to the parent. – CBroe Apr 19 '13 at 13:10

1 Answers1

0

Try this:

// Get the iFrame jQuery Object
var $MyFrame = $("#iframeid");

// You need to wait for the iFrame content to load first
// So, that the click events work properly
$MyFrame.load(function () {
    var frameBody = $MyFrame.contents().find('body');

    // Set the iFrame height
    $MyFrame.css({
        height: frameBody.outerHeight()
    });
});
palaѕн
  • 72,112
  • 17
  • 116
  • 136