iframe无边框度自适应

iframe无边框度自适应

<iframe src="http://www.httple.net" style="width:100%;height:1100px" name="iframe_a"  frameborder="no" id="ifr" border="0" marginwidth="0" marginheight="0" scrolling="no" allowtransparency="yes"></iframe>    
    <script>
        // 计算页面的实际高度,iframe自适应会用到
        function calcPageHeight(doc) {
            var cHeight = Math.max(doc.body.clientHeight, doc.documentElement.clientHeight)
            var sHeight = Math.max(doc.body.scrollHeight, doc.documentElement.scrollHeight)
            var height = Math.max(cHeight, sHeight)
            return height
        }
        window.onload = function () {
            var height = calcPageHeight(document)
            parent.document.getElementById('ifr').style.height = height + 'px'
        }
    </script>

你可能感兴趣的:(PHP,javascript,前端,html)