【发布时间】:2010-10-15 10:19:12
【问题描述】:
如何在 HTML iFrame 中检测滚动条的存在(使用 Javascript)?
我已经试过了:
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 Inspector 上搜索了 javascript 对象,但没有找到任何东西。
是否可以在 javacscript 的 iframe 中检测到滚动条的存在?
iframe 内容来自同一个域。
直到现在都没有成功..
【问题讨论】:
标签: javascript html dom iframe scrollbar