今天又一次研究了iframe自适应高度,下面的代码确实可行。

<html>
<head>
    <script type="text/javascript">
    function SetCwinHeight()
    {
        var ifm = document.getElementById("dd");
        var subWeb = document.frames ? document.frames["dd"].document : ifm.contentDocument;
        if (ifm != null && subWeb != null)
        {
            ifm.height = subWeb.body.scrollHeight;
        }  
    }
    </script>
</head>
<body>
    <button type="button" onclick="document.getElementById('dd').src='b.html';">
        A</button>
    <button type="button" onclick="document.getElementById('dd').src='c.html';">
        B</button>
    <iframe id="dd" src="b.html" onload="SetCwinHeight();" frameborder="0" width="100%" scrolling="no" marginheight="0" marginwidth="0" />
</body>
</html>