Posted By

jamesming on 10/14/08


Tagged


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

ntulip
glends


Resizing an iframe according to its contents


 / Published in: JavaScript
 

URL: http://guymal.com/mycode/iframe_size/

  1. <script language="JavaScript">
  2. <!--
  3. function calcHeight()
  4. {
  5. //find the height of the internal page
  6. var the_height=
  7. document.getElementById('the_iframe').contentWindow.
  8. document.body.scrollHeight;
  9.  
  10. //change the height of the iframe
  11. document.getElementById('the_iframe').height=
  12. the_height;
  13. }
  14. //-->
  15. </script>
  16.  
  17. and in the body create the iframe tag:
  18.  
  19. <iframe width="700" id="the_iframe"
  20. onLoad="calcHeight();"
  21. src="testing_page.shtml"
  22. scrolling="NO"
  23. frameborder="1"
  24. height="1">
  25. An iframe capable browser is
  26. required to view this web site.
  27. </iframe>

Report this snippet  

You need to login to post a comment.