Iframe自适应高度

@{
    ViewBag.Title = "首页";
    Layout = "~/Views/Shared/_Layout_0.cshtml";
}
<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="/Index/Index" id="iframepage" name="iframepage" onload="iFrameHeight()" style="width:100%" border="0" vspace="0" hspace="0" marginwidth="0" marginheight="0" framespacing="0" frameborder="0" scrolling="no"></iframe>

 

posted @ 2016-05-23 14:55  团子先生  阅读(220)  评论(0编辑  收藏  举报