Css 无法控制iframe高度
我面临着iframe高度的绞合问题 在它的父页面中,我们将其高度设置为900px,如下所示:Css 无法控制iframe高度,css,iframe,height,Css,Iframe,Height,我面临着iframe高度的绞合问题 在它的父页面中,我们将其高度设置为900px,如下所示: <html lang="en-us"> <head> <?php include_once "./includes/header.php"; ?> </head> <body> <?php include_once "./includes/top.php" ?>
<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>
我还发现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;
有什么问题吗?对于嵌入了
iframe
的HTML文档,JavaScript代码只需将iframe
元素的height
属性的值加30即可。这解释了值930。与这里的目标相反,您得到的scrollHeight
值只是内联框架元素的高度,而不是嵌入文档的内在高度要求
对于非HTML类型的嵌入式文档,可能会发生奇怪的事情。例如,如果它是纯文本文件,
scrollHeight
值可能反映从其中的行数派生的内在高度要求。在不知道服务器在请求/modules/ophthallogy/patients.php
时返回什么的情况下,我只能猜测这是非HTML的内容。我解决了这个问题。这是由错误的js代码引起的。我把它拿走了,没关系。
<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">
#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;
}
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;