<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() {
// 動態加載iframe. iframe的大小,必須在同一個域中才可以這樣計算.
$("#info").load(function(data) {
$(this).height($(this).contents().find("#wrapper").height());
$(this).width($(this).contents().find("#wrapper").width());
// 對于寬度,不要使用find("body"),這個返回的值不準確
}).attr("src", "2col.html");
$("#ifm").load(function() {
// 自動適應iframe的大小,不用像上一個方法那樣麻煩的
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>