<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8">
<style type="text/css"></style>
<script src="js/jquery.js"></script>
<script type="text/javascript">
/*To determine the size of the IFrame's contents, you must access the height and width properties of the underlying IFrame document. Because you only have scripting access to pages that are hosted in the same domain, you can only access the properties to the pages that are hosted within the same domain (for example, Cross Frame Scripting). Therefore, the source document of the IFrame must be from the same domain as the page that contains the IFrame. From: http://support.microsoft.com/kb/278469*/
$(function() {
// 動(dòng)態(tài)加載iframe. iframe的大小,必須在同一個(gè)域中才可以這樣計(jì)算.
$("#info").load(function(data) {
$(this).height($(this).contents().find("#wrapper").height());
$(this).width($(this).contents().find("#wrapper").width());
// 對(duì)于寬度,不要使用find("body"),這個(gè)返回的值不準(zhǔn)確
}).attr("src", "2col.html");
$("#ifm").load(function() {
// 自動(dòng)適應(yīng)iframe的大小,不用像上一個(gè)方法那樣麻煩的
var body = this.contentDocument.body;
this.style.pixelWidth = body.scrollWidth;
this.style.pixelHeight = body.scrollHeight;
}).attr("src", "2col.html");
});
</script>
</head>
<body>
Size of iframe<br>
<!--<iframe src="2col.html" id="info" name="info" frameborder="0" scrolling="no" marginwidth="0" marginheight="0"></iframe>-->
<iframe id="ifm" src="2col.html" frameBorder=0 scrolling=no>
</body>
</html>