楼主这样MS有点杀鸡用牛刀,
也许真的没有考虑清楚,
何必这样呢,你所谓的控件输出出来的iframe,没有滚轴?
如果这样的话,你在父窗口再来控制iframe,有点不太可能!
换个思路试试吧

解决方案 »

  1.   

    参见:
    http://www.v-ec.com/jslib/【Iframe滚动兼容】部分!
      

  2.   

    控件输出来的iframe是有滚动条的,但是我把iframe的长和宽都设的很大,所以iframe撑开了,滚动条就没了。
      

  3.   

    iframe自适应?
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>iframe</title>
    </head>
    <body>
    <script type="text/javascript">
    function SetCwinHeight(){
      var bobo=document.getElementById("bobo"); //iframe id
      if (document.getElementById){
       if (bobo && !window.opera){
        if (bobo.contentDocument && bobo.contentDocument.body.offsetHeight){
         bobo.height = bobo.contentDocument.body.offsetHeight;
        }else if(bobo.Document && bobo.Document.body.scrollHeight){
         bobo.height = bobo.Document.body.scrollHeight;
        }
       }
      }
    }
    </script>
    <iframe width="100%" id="bobo" onload="Javascript:SetCwinHeight()" height="1" frameborder="0" src="IFrame_myPage.aspx"></iframe>
    其实很简单</body>
    </html>
      

  4.   

    我现在在父页面找不到iframe的滚轴事件,是因为这个iframe是动态生成的吗
      

  5.   

    动态生成的?
    那也应该有id吧? 不会动态生成的就找不到吧?
    无论如何生成,在客户端还是一样的html代码啊!
      

  6.   

    谢谢xiaojing7的帮忙,我的那个iframe是别的控件生成出来的,引用的时候不能直接写 <iframe>...</iframe>
    就是<iframe width="100%" id="bobo" onload="Javascript:SetCwinHeight()" height="1" frameborder="0" src="IFrame_myPage.aspx"></iframe>
    这句在父页面上是没有的要等到iframe生成出来后给iframe加上onload事件,怎么加呢,谢谢。            
      

  7.   

    <iframe width="100%" id="bobo" onload="Javascript:SetCwinHeight()" height="1" frameborder="0" src="IFrame_myPage.aspx"> </iframe>这句也是动态生成出来的
      

  8.   

    那就控制,生成结束后,
    然后
    var obj = document.getElementById("bobo");
    obj.setAttribute("onclick", "Javascript:SetCwinHeight()");
      

  9.   

    代码加上了,但是点击 iframe 没有反应,是不是iframe的onclick事件没有加上呢
      

  10.   

    你这个方法加在什么地方了?
    确保你的ifream已经生成了?
      

  11.   

    if(document.readyState == "complete")
                        {
                            obj.setAttribute("onclick", "Javascript:SetCwinHeight()");
                        }这样加的
      

  12.   

    汗!我写错方法了。怎么能用onclick呢!
    应该是onload不好意思!你用onload再试下,刚没看清楚,写错了!
      

  13.   

     bobo.height = bobo.contentDocument.body.offsetHeight;
    这句使iframe在父页面上出现滚动条吧,我不能让iframe在父页面上出现滚动条
      

  14.   

    不让iframe出现滚动条,父页面上有滚动条,鼠标在iframe的区域上滚动时等于用的是父页面的滚动条
    相当于 iframe.滚轴事件 = 父页面.滚轴事件
      

  15.   

    好的,谢谢,能留个msn吗