簡體   English   中英

如何檢測iframe中頁面的高度?

[英]How to detect height of page inside iframe?

我在頁面中有一個iframe

<iframe src="page.aspx" > 

我不知道這件事有多大。 如何獲得高度? 由於瀏覽器的差異性,jQuery在這里可能會很好。

// sth like this. 
currentfr.contentDocument.body.offsetHeight // NS 
currentfr.Document.body.scrollHeight // IE 

喜歡您的代碼,但是您對其進行了一些增強以避免錯誤

if (window.innerWidth) { //if innerWidth is defined
      // the standard
      w = fr.width,
      h = fr.height
 }
else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0) {
       // IE6
       w = fr.document.documentElement.clientWidth,
       h = fr.document.documentElement.clientHeight
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM