如果页面中嵌套iframe,而且要使iframe自适应高度,这时需要在iframe中套用的页面中使用parent.window......来获取父页面的内容,那么如果主页面与嵌套页面不是在一个域中时,便得不到任何想要的结果,因此,页面如果在本地打开而不是在服务器上或者说在服务器上但不在同一个项目中时,便起不到任何作用。
代码如下:
A页面中嵌套B页面
A页面:
<iframe src="<{$url}>" class="iframe-list" scrolling="no" background-color=transparent " id="iframepage" name="iframepage" allowTransparency="true"></iframe>
B页面中的js:
$(window.parent.document).find("#iframepage").load(function(){
var main = $(window.parent.document).find("#iframepage");
var thisheight = $(document).height();
main.height(thisheight);
});