获取iframe自适应后的宽高

1.同域

一:引入jquery

<script type="text/javascript" src="../jquery.min.js"></script>

二:设置iframe的src

<iframe src="http://localhost/mc/demo3.html" marginwidth="0"  marginheight="0" width="100%" height="100%" id="iframe111" frameborder="0" scrolling="no" onload="reinitIframe()" ></iframe>

三:加载函数

function reinitIframe(){
        var height = $('#iframe111').contents().find('body').height();
        console.log(height);        
    }

 

posted on 2018-03-11 00:15  薇薇123456  阅读(171)  评论(0编辑  收藏  举报

导航