문제

I am using this script to resize iframe height and width automatically based on the content..

<script language="JavaScript">


function autoResize(id){
    var newheight;
    var newwidth;

    if(document.getElementById){
        newheight=document.getElementById(id).contentWindow.document .body.scrollHeight;
        newwidth=document.getElementById(id).contentWindow.document .body.scrollWidth;
    }

    document.getElementById(id).height= (newheight) + "px";
    document.getElementById(id).width= (newwidth) + "px";
}
</script>

Calling this function in Iframe onload..

<iframe src="index.htm" scrolling='no'  width="100%" height="100%" name="CHANGETHIS" id="CHANGETHIS" marginheight="0" frameborder="0" onLoad="autoResize('CHANGETHIS');"></iframe>

Consider I am using hyperlink <a href="index2.htm">Redirect</a>

If I click Redirect hyperlink, it is redirecting to index2.htm file with iframe auto resize based on the content. If I go back (browser back or back button) to the previous page (index.htm), iframe auto resize is not working only in firefox..It is working fine in IE..

Is there any solution for this to work also in firefox using javascript or jquery?

도움이 되었습니까?

해결책

Use this: onresize="autoResize('CHANGETHIS');"

<iframe src="index.htm" scrolling='no'  width="100%" height="100%" name="CHANGETHIS" id="CHANGETHIS" marginheight="0" frameborder="0" onload="autoResize('CHANGETHIS');" onresize="autoResize('CHANGETHIS');"></iframe>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top