0

I'm trying to resize an iframe. My code is working in Chrome and Interner Explorer, but not in Firefox. Can someone explain why.

Here's my javascript:

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

function autoResize(id){
var newheight;


if(document.getElementById){
    newheight=document.getElementById(id).contentDocument .body.scrollHeight;

}

document.getElementById(id).height= newheight;

}
</script>

And here is my iframe:

<iframe id="myframe" src="http://www.somesite.com/content/index.php" frameborder="0" scrolling="no" width="900px" onLoad="autoResize('myframe');"></iframe>
pckill
  • 3,709
  • 36
  • 48

1 Answers1

0

Maybe because you are not sending passing the id as parameter in function call in if statement. Try this:

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

    function autoResize(id){

    if(document.getElementById(id)){
        document.getElementById(id).height = document.getElementById(id).contentDocument .body.scrollHeight;

    }
}
</script>
Jehanzeb.Malik
  • 3,332
  • 4
  • 25
  • 41