我的页面中有一个 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
}
关于javascript - 如何检测iframe内页面的高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2362565/