Script to resize iframe to fit the content it loads?

Hello,

I am still trying to find a method to be able to dynamically resize the iframe to fit the height of the html it loads.

Each html I have created has a different height.
I tried this script:

<script type="text/javascript">function iSize(){
document.getElementById('mainFrame').height = document.getElementById('mainFrame').contentWindow.document.body.scrollHeight + "px";
}
</script>

The issues I found:

  • Chrome(latest): It doesn’t work
  • IE 8: It works…
  • Firefox(latest): It works…

Any suggestions? I’ve been working on this for days…:d: