Martin Ongtangco
Martin Ongtangco

Reputation: 23515

constantly resizing iframe to contents via Jquery

if found this solution on the web that re-sizes the iFrame on load. I was wondering how I can do this by setting an loop that constantly check's the active iframe's content size then resize it instantly

any ideas on how to do this on Jquery? Thanks!

Upvotes: 2

Views: 957

Answers (1)

smaglio81
smaglio81

Reputation: 511

You could try putting the code which changes the size of the iframe within the iframe page. When the iframe page loads, it can use jQuery to search for DOM elements within it's parent window. The javascript to do with would look like:

$(function () {
    var height = $(document).height();
    $('iframe', window.parent.document).height(height + 'px');
});

Upvotes: 1

Related Questions