日期:2014-05-16  浏览次数:20520 次

关于Chrome中iframe的scrolling问题。
HTML code

<html>
<head>
<script type="text/javascript">
  function showS()
  {
    document.getElementById("test").scrolling="yes";
  }
  function hideS()
  {
    document.getElementById("test").scrolling="no";
  }
</script>    
</head>
<body>
    <div wedth:600px;height:600px" onmouseover="showS()" onmouseout="hideS()">
        <iframe id="test" scrolling="no" width="600px" height="600px" frameborder="0" src="http://www.csdn.net">
        </iframe>
    </div>
</body>
</html>


鼠标悬浮,显示滚动条,鼠标离开,隐藏滚动条。
在Firefox达到预期效果。在Chrome和IE却总是不能显示滚动条?万分不解,求解。

------解决方案--------------------
你的HTML代码中 Div样式 笔误了吧

<div style="width:600px;height:600px" onmouseover="showS()" onmouseout="hideS()">
<iframe id="test" scrolling="no" width="600px" height="600px" frameborder="0" src="http://www.csdn.net">
</iframe>
</div>
------解决方案--------------------
属性里面还能加单位啊?不如用style.overflowX='scroll';
------解决方案--------------------
<div wedth:600px;height:600px" onmouseover="showS()" onmouseout="hideS() "; style="scolling="no">
------解决方案--------------------
chrome时而好,IE6多出空白
HTML code
 
<html>
<head>
<script type="text/javascript">
function showS()
{
  document.getElementById("test").scrolling="yes";
  document.getElementById("test").style.overflow="scroll";
  //alert(document.getElementById("test").scrolling);
 
}
function hideS()
{
  document.getElementById("test").scrolling="no";
  document.getElementById("test").style.overflow="hidden";
  //alert(document.getElementById("test").style.overflow);
}
</script> 
<style>
.ifr{width:600px;height:600px;background:#f60;overflow:hidden;display:block;position:relative;}

</style>
</head>
<body>
  <div class="ifr" onMouseOut="hideS()" onMouseOver="showS()">
    <iframe id="test" width="580px" height="580px" frameborder="0" src="" style="margin:10px;" > </iframe>
    <script language="JavaScript"> 
      var iframe = document.getElementById("test"); 
      iframe.src = "http://www.ok22.org";
      //以下判断iframe是否加载完,并且隐藏滚动条
      if (iframe.attachEvent){
        iframe.attachEvent("onload", function(){               
          hideS();
          //document.getElementById("loading").style.display="none"; 
        }); 
      } else { 
        iframe.onload = function(){
          hideS();