我遇到了iframe高度的問題。無法控制iframe高度
在它的父頁面,我們設置它的高度= 900px,這樣的:
<html lang="en-us">
<head>
<?php include_once "./includes/header.php"; ?>
</head>
<body>
<?php include_once "./includes/top.php" ?>
<?php include_once "./includes/left_nav.php" ?>
<section id="content">
<iframe width="100%" height="900" id="myFrame" src="./modules/ophthalmology/patients.php" scrolling="no" frameborder="0">
</iframe>
</section>
<?php include_once "./includes/footer.php" ?>
</body>
</html>
,但它不能顯示它裏面的所有內容。我查的螢火蟲元素,然後發現:
<iframe id="myFrame" width="100%" scrolling="no" height="208" frameborder="0" src="./modules/ophthalmology/patients.php">
高度改爲208
但在另一個模塊,它的源代碼:
<html lang="en-us">
<head>
<?php include_once "./includes/header.php"; ?>
</head>
<body>
<?php include_once "./includes/top.php" ?>
<?php include_once "./includes/left_nav.php" ?>
<section id="content">
<iframe width="100%" height="900" id="myFrame" src="./modules/csvfileupload/index.html" scrolling="no" frameborder="0">
</iframe>
</section>
<?php include_once "./includes/footer.php" ?>
</body>
</html>
將其改爲:
<iframe id="myFrame" width="100%" scrolling="no" height="930" frameborder="0" src="./modules/csvfileupload/index.html">
這兩個唯一的區別是src文件不同,首先是patients.php,第二個是index.html。所有其他人都一樣。
我已經檢查的內容元素,它的CSS:
#content {
border: 1px solid;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
margin: 0;
min-height: 600px;
overflow: visible;
padding: 15px 5px 15px 230px;
}
而且我還發現有在的header.php一個js函數:
function sizeFrame() {
var F = document.getElementById("myFrame");
if(F.contentDocument) {
F.height = F.contentDocument.documentElement.scrollHeight+30; //FF 3.0.11, Opera 9.63, and Chrome
} else {
F.height = F.contentWindow.document.body.scrollHeight+30; //IE6, IE7 and Chrome
}
}
window.onload=sizeFrame;
什麼問題?
我修復了這個問題。它是由錯誤的js代碼引起的。我刪除它,沒關係。 – PhilipSong 2012-08-11 23:17:25