如何检测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检查器上的javascript视图,但是没有找到任何东西。
是否可以在javacscript中的iframe中检测到滚动条的存在?
iframe内容来自同一个域。
直到现在还没有成功..。
alt text http://www.upvtp.com.br/file.php/1/help_key.jpg
发布于 2009-03-25 11:24:31
由于JavaScript的安全限制,我认为如果iframe内容来自另一个域,则无法做到这一点。
编辑:在这种情况下,给iframe取一个名称=‘someframe’和id=‘someframe 2’,然后将框架‘someframe’.document.body. of与document.getElementById('someframe2').offsetWidth进行比较,就可以给出答案。
https://stackoverflow.com/questions/681087
复制相似问题