0

I have a iframe which fill with ssrs report dynamically so when report is fetched iframe is not displaying based on the report height.It even doesn't show scroll when iframe set to 100%. how to get the height of the iframe dynamically

Below is the iframe I use

1 Answers1

0

Maybe duplicate of Adjust width height of iframe to fit with content in it

<script type="application/javascript">

function resizeIFrameToFitContent( iFrame ) {

    iFrame.width  = iFrame.contentWindow.document.body.scrollWidth;
    iFrame.height = iFrame.contentWindow.document.body.scrollHeight;
}

window.addEventListener('DOMContentReady', function(e) {

    var iFrame = document.getElementById( 'iFrame1' );
    resizeIFrameToFitContent( iFrame );

    // or, to resize all iframes:
    var iframes = document.querySelectorAll("iframe");
    for( var i = 0; i < iframes.length; i++) {
        resizeIFrameToFitContent( iframes[i] );
    }
} );

</script>

<iframe src="yoursource.html" id="iFrame1"></iframe>
Community
  • 1
  • 1
technico
  • 1,192
  • 1
  • 12
  • 22
  • 3
    If you think a question is a duplicate, flag it for closing. – Alexander O'Mara Aug 03 '16 at 01:11
  • Hi technico.i tried with your solution but i got access denied exception when i am trying to access contentwindow of a iframe – user123412 Aug 03 '16 at 12:35
  • I'm confident about the fact you did change the iframe src value to fit your need. So this issue may come from the [domain origin policy](http://stackoverflow.com/questions/364952/jquery-javascript-accessing-contents-of-an-iframe), which disable the possibility to acces the iframe content DOM, if the domain name don't match between main page and iframe page. – technico Aug 03 '16 at 16:12