过去两天有一个问题一直困扰着我:(
我已经设置了一个HTML网页,其中包含 iFrame ,可以加载框架集文档。是的我知道,框架是古老的技术,不应该使用,但这是Adobe的RoboHelp工具产生的输出,所以我需要处理它。
我尝试添加JavaScript代码的变体,这些代码会调整iFrame的高度以适应浏览器窗口的剩余高度。它在Chrome,Safari,Firefox等中运行良好,但与大多数组织一样,客户端已经标准化为古老的IE(Internet Explorer 8),看起来它们不会很快向前发展。
此处传达了当前问题的图像:
简单地说,我无法让iFrame占用 Internet Explorer (8)中横幅和页脚之间剩余的空间。我已经使用CSS样式和JavaScript代码的变体来“读取”(我猜)“frameset(?)”文档的高度,以便将高度传递给内部框架以调整其大小。我见过的大多数脚本都依赖于iFrame中文档的高度,但是当你有一个框架集时会发生什么?
以下是包含iFrame的主页的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style>
body {
width:100%;
height:100%
}
</style>
<script language="javascript" type="text/javascript">
function autoHeight(e)
{
alert(e);
if ( e.contentDocument ) {
e.height = e.contentDocument.body.offsetHeight + 35;
}
else {
e.height = e.contentWindow.document.body.scrollHeight + 35;
alert("e.contentWindow = "+ e.contentWindow);
}
}
this.onload = function(e) {
// or add it to the onload attribute of the body tag...
var ifr = document.getElementById('helpFrame');
autoHeight(ifr);
}
</script>
</head>
<body>
<!--banner code here, not too important -->
<iframe frameborder="0" id="helpFrame" align="bottom" src="/RCMP/prod/index.htm" width="100%" height="100%" scrolling="no" style="height:100%;">
Your browser does not support iframes.
</iframe>
<!-- added some paragraphs to actually "push" the footer down for now. -->
<p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p>
<!--footer code here-->
</body>
</html>
这是框架集的代码(包含在iFrame中,来自Adobe的RoboHelp发布的输出)。很多javascript都可以忽略,我相信重点是框架集)
<html>
<head>
<link rel="shortcut icon" href="favicon.ico">
<title>Orientation Guide To E-Division Headquarters</title>
<meta name="generator" content="Adobe RoboHelp 9" />
<meta name="description" content="WebHelp 5.50" />
</head>
<frameset cols="100%,*" frameborder=no border=0>
<frame src="whnjs.htm">
<frame src="whskin_blank.htm" noresize>
</frameset><noframes></noframes>
</html>
因此,挑战是让IE框架中的iFrame全高(直到页脚)!任何建议/解决方案将不胜感激。如果我不需要,我真的不想使用jQuery - JavaScript和CSS会很好。
谢谢!