Iframe跨域自适应高度:
父页面(地址是:http://www.aosachina.com/test/index.html) <iframe id="iframeB" name="iframeB" src="http://aosa.eee114.com" width="100%" height="auto" scrolling="no" frameborder="0"></iframe> 若不兼容可用 <frameset rows="*" frameborder="no" border="0" framespacing="0" width="100%" height="auto"> <frame src="http://aosa.eee114.com" id="iframeB" name="iframeB" /> </frameset> 中间页(http://www.aosachina.com/test/current.html): <script type="text/javascript"> function pseth() { var iObj = parent.parent.document.getElementById('iframeB'); //A和main同域,所以可以访问节点 var iObjH = parent.parent.frames["iframeB"].frames["iframeA"].location.hash; //访问自己的location对象获取hash值 iObj.style.height = iObjH.split("#")[1] + "px"; //操作dom } pseth(); </script> 被嵌套页(http://aosa.eee114.com): <iframe id="iframeA" name="iframeA" src="" width="0" height="0" style="display:none;" ></iframe> <script type="text/javascript"> function sethash(){ var hashH = document.documentElement.scrollHeight; //获取自身高度 var urlC = "http://www.aosachina.com/test/current.html"; //设置iframeA的src document.getElementById("iframeA").src=urlC+"#"+hashH; //将高度作为参数传递 } window.οnlοad=sethash; </script>转载于:https://www.cnblogs.com/victorydou/archive/2012/04/17/2454045.html
相关资源:iframe跨域嵌套自适应高度