首页 > 代码库 > ifame_自适应高度

ifame_自适应高度

<!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>一键分享</title>
</head>

<body>
<script src="http://www.mamicode.com/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" language="javascript">

    function iFrameHeight() {

        var ifm= document.getElementById("iframepage");

        var subWeb = document.frames ? document.frames["iframepage"].document :

    ifm.contentDocument;

            if(ifm != null && subWeb != null) {

            ifm.height = subWeb.body.scrollHeight;

            }

    }

</script>
 <iframe src="http://www.mamicode.com/#"  width="100%" height="auto" frameborder="0" marginheight="0" marginwidth="0" id="iframepage" name="iframepage" onl oad="iFrameHeight()" scrolling="no"></iframe>
</body>
</html>

ifame_自适应高度