2011-02-25 58 views
0

我有一些奇怪的問題,我的iframe身高。如何獲得真正的iframe身高?

在我的編輯器中,鍵入區域可調整大小,所以在14行之後,增加的停止位置和滾動條顯示。刪除一些行後,滾動條隱藏,高度應該開始下降。但它不...因爲我不能讀取滾動條隱藏後的真實iframe身高。

您可以在此處找到我的編輯器:http://brownfolder.com/09/ - 身高低於編輯器,每100ms更新一次。

順便說一句,Firebug標誌着它的真實尺寸的身體,而不是這個越野車的一個。

的代碼我使用:

var s = document.getElementById(rte); 
var x = s.contentWindow.document; 
var timer = setInterval(function() 
{ 
     var h = x.body.scrollHeight; 
     $('.aasdf').text(h); 
     if(h > maxheight) 
     { 
      $(s).height(maxheight); 
      x.body.parentNode.style.overflow = "auto"; 
      clearInterval(timer); 
     } 
     else if(h <= minheight) 
      $(s).height(minheight); 
     else 
     { 
      x.body.parentNode.style.overflow = "hidden"; 
      $(s).height(h); 
     }   
}, 100); 

你有任何想法如何解決這個問題?

在此先感謝!

回答

-1
<iframe style="height:200px" id="if" onload="change()"></iframe> 

<script type="text/javascript"> 
function change() 
{ 
    var a = document.getElementById('if'); 
    var b = a.style.height; 
    alert(b); 
} 
</script> 

此代碼將幫助你獲得iframe的高度..!這可能有所幫助。 祝你有美好的一天。

相關問題