4

Hello after hours of search i found a script that works for my iframe exept a little problem it never stops it increases the height with no stop... here is the code i add this script at my page i want the iframe

<script>
  function alertsize(pixels){
    pixels+=0;
    document.getElementById('myiframe').style.height=pixels+"px";
  }
</script>
<script type="text/javascript">
  var myHeight = 0;

  setInterval(function(){
    if(myHeight != document.body.scrollHeight){
      myHeight = document.body.scrollHeight;
      parent.alertsize(myHeight);
    }
  },500);
</script>

here is iframe:

<iframe id="myiframe" src="http://www.altasoft.gr/hermes/index.html"
        name="myiframe" width="100%" height="100%" scrolling="no"
        frameborder="0"></iframe>
John Willemse
  • 6,608
  • 7
  • 31
  • 45
Ant Mar
  • 145
  • 1
  • 2
  • 9
  • 1
    Also noticed this problem some time ago. I pseudo-solved it by setting a fix height for my Iframe at page load in relevance to the device's screen size. Dunno if this actually can be fixed finally. – Corsair May 21 '13 at 12:47
  • 1
    Use a css reset and reset the value for iframe. Something like iframe{ margin:0 padding:0 height:0 width:0} – Rinku May 21 '13 at 12:54
  • thx for fast answer Rinku / Corsair can you write me an exaple? because im not sure how to do it ... thx! – Ant Mar May 21 '13 at 13:10
  • Can you explain what your objective is? – Kaf May 21 '13 at 13:28
  • If your objective is that your iframe occupies 100% height and width there are easiest solutions with css http://stackoverflow.com/questions/5867985/iframe-100-height – PoseLab May 21 '13 at 15:30
  • I want an iframe that will increase or decrease height depending on the page it loads – Ant Mar May 22 '13 at 09:16

1 Answers1

0

The problem is the height="100%" in your markup. Change it to a fixed pixel value, and the script will start working. So change height="100%" to height="1" or whatever, the exact value doesn't really matter.

rvighne
  • 20,755
  • 11
  • 51
  • 73