我如何使用JavaScript检测HTML iFrame中滚动条的存在?
我已经尝试过:
var vHeight = 0;
if (document.all) {
if (document.documentElement) {
vHeight = document.documentElement.clientHeight;
} else {
vHeight = document.body.clientHeight
}
} else {
vHeight = window.innerHeight;
}
if (document.body.offsetHeight > vHeight) {
//when theres a scrollbar
}else{
//when theres not a scrollbar
}
我也曾尝试过:
this.scrollLeft=1;
if (this.scrollLeft>0) {
//when theres a scrollbar
this.scrollLeft=0;
}else{
//when theres not a scrollbar
return false;
}
一直没有成功...
我在DOM检查器上搜索了JavaScript对象,但没找到什么内容。
是否可能在 JavaScript 中检测 iframe 中是否存在滚动条?
iframe 的内容来自同一域。
目前为止还没有成功。
documentElement
? - babvar root = document.scrollingElement;
替换compatMode
检查。 - Robbendebiene