0

hi
I have 1 iframe which includes another iframe it and I want to auto height both frames whenever any activity peform in the iframe it load the new page and auto height according to the 2nd (inner iframe)

the code which i am currenlty using in main page and in 1st iframe is as follow please check and help me thank you

<script language="javascript" type="text/javascript">

  function resizeIframe(obj) {
    obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';

  }

</script>
2
Contributors
3
Replies
10
Views
3 Years
Discussion Span
Last Post by rpv_sen
0

Hi

Javascript Code

<script language="javascript">


    function sizeToMyContent( ifRef, setW, setH, fMargin ) { //alert(ifRef);
        var ifDoc, margin = typeof fMargin === 'number' ? fMargin : 6; 
        try { 
            ifDoc = document.getElementById(ifRef).contentWindow.document.documentElement;
            }
        catch( e ) { 
            ifDoc = null;
            }       
        if( ifDoc ) {    
            if( setH ) {
                document.getElementById(ifRef).height = ifDoc.scrollHeight + margin + "px"; 
                }
            if( setW ) {
                document.getElementById(ifRef).width = ifDoc.scrollWidth + margin + "px";
                }
            }  
        }
</script>

HTML Code

<iframe id="Iframe2" name="thisframe" src="filename.html" width="750px" onload="sizeToMyContent(this.id, false, true);"></iframe>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.