Guest User

Untitled

a guest
Jun 24th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. function resizeFrame(){
  2. var frame = parent.document.getElementsById(window.me);
  3. frame.style.height = document.offsetHeight;
  4. }
  5.  
  6. //init function
  7. bunding.doSomeWork(callbackFunction);
  8. ...
  9.  
  10. function callbackFunction()
  11. {
  12. //does some HTML output
  13. resizeFrame();
  14. }
  15.  
  16. <!DOCTYPE html>
  17. <html>
  18. <head>
  19. <title>so-iframeResize</title>
  20. <script type="text/javascript" >
  21.  
  22. onframeload=function(iframe) {
  23. var doc = iframe.contentWindow.document;
  24. iframe.style.height = Math.max(
  25. doc.getElementsByTagName("html")[0].offsetHeight,
  26. doc.body.offsetHeight // IE prefers this value
  27. ) + "px";
  28. };
  29.  
  30. </script>
  31. </head>
  32. <body>
  33. <div id="page">
  34. <iframe src="about:blank" onload="onframeload(this)">
  35. </iframe>
  36. </div>
  37. </body>
  38. </html>
Add Comment
Please, Sign In to add comment