iframe无边框
<iframe src="home.html" id="frmDialog" width="1000" height="710" frameborder="0" scrolling="auto" align="top" marginheight="0" marginwidth="0"></iframe>
jquery控制iframe自动高适应
var frame = $("#frmDialog");
frame.height(frame.contents().find("body").height() + 40);
frame.load(function(){
$(this).height($(this).contents().find("body").height() + 40);
});
返回值:jQuery.contents()
V1.2概述
查找匹配元素内部所有的子节点(包括文本节点)。如果元素是一个iframe,则查找文档内容
示例
描述:
查找所有文本节点并加粗
HTML 代码:
<p>Hello <a href="http://ejohn.org/">John</a>, how are you doing?</p>
jQuery 代码:
$("p").contents().not("[nodeType=1]").wrap("<b/>");
结果:
<p><b>Hello</b> <a href="http://ejohn.org/">John</a>, <b>how are you doing?</b></p>
描述:
往一个空框架中加些内容
HTML 代码:
<iframe src="/index-blank.html" width="300" height="100"></iframe>
jQuery 代码:
$("iframe").contents().find("body")
.append("I'm in an iframe!");
参考: jquery1.7_20120209.chm