Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 0.60 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Why does the content height of my <iframe> keep increasing?
  2. $("#iFrame").load(function () { resizeIframe(); }); // on load resize is called
  3. loadIFrame(url); //this loads url in i frame
  4.  
  5.  
  6.  
  7. function resizeIframe() {
  8.     var iFHeight = $('iFrame').contents().height();
  9.     var iFWidth = $('iFrame').contents().width();
  10.  
  11.     $("#content").css("height", iFHeight);
  12.     $("#content").css("width", iFWidth);
  13. }
  14.        
  15. $('iframe').load(function(){
  16.     var $body = $(this).contents().find('body');
  17.     $("#content").css({
  18.         height: $body.height(),
  19.         width: $body.width()
  20.     });
  21. })
  22. .attr('src', 'iframeUrlHere');