我对网页设计和脚本很陌生。我正在尝试构建一个顶部有横幅框架、左侧菜单和右下角大部分的主要内容的站点。我希望横幅随浏览器大小动态调整大小。我在 IE8 上完成了此操作,但在 IE9 上无法正确查看,另外我想要一个跨越框架边界的背景图像我目前正在尝试 iframe,但不能让它们填充浏览器窗口。有时,我可以使 iframe 动态更改大小和/或位置,但它不可靠。我尝试了各种位置类型以及将 iframe 包装在其中并尝试调整它们的大小和位置。这是我拥有的最成功的代码,请原谅任何多余的、未引用的和注释的代码,因为它是失败尝试的剩余部分。
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<title>Mountain Girl Gallery</title>
<style media="screen" type="text/css">
<!--
#layer1 { position: absolute; top: 0px; left: 0px; width: 1000px; height: 95px; visibility: visible}
--!>
<!--
#layer2 { position: absolute; top: 95px; left: 500px; width: 100px; height: 505px; visibility: visible}
--!>
<!--
#layer3 { position: absolute; top: 95px; left: 100px; width: 900px; height: 505px; visibility: visible}
--!>
</style>
<script type="text/javascript">
function frameResize(){
var winW;
var winH;
if (document.body && document.body.offsetWidth) {
winW = document.body.offsetWidth;
winH = document.body.offsetHeight;
}
if (document.compatMode=='CSS1Compat' &&
document.documentElement &&
document.documentElement.offsetWidth ) {
winW = document.documentElement.offsetWidth;
winH = document.documentElement.offsetHeight;
}
if (window.innerWidth && window.innerHeight) {
winW = window.innerWidth;
winH = window.innerHeight;
}
var bframe=document.getElementById('bannerframe');
//var menuframe=document.getElementById('menu');
var mframe=document.getElementById('main');
//var f1=document.getElementById('bannerframe');
//var f2=document.getElementById('menu');
//var f3=document.getElementById('main');
bframe.style.width=winW;
bframe.style.height=winH*.2;
//menuframe.style.width=winW*.15;
//menuframe.style.height=winH*.8;
//menuframe.style.top=(winH*.2)+"px";
mframe.style.width=winW*.85;
mframe.style.height=winH*.8;
mframe.style.top=(winH*.2)+"px";
mframe.style.left=(winW*.15)+"px";
//f1.style.width=bframe.style.width;
//f1.style.height=bframe.style.height;
//menuframe.style.width=winW*.15;
//menuframe.style.height=winH*.8;
//f2.style.top=menuframe.style.top;
//f3.style.width=mframe.style.width;
//f3.style.height=mframe.style.height;
//f3.style.top=mframe.style.top;
//f3.style.left=mframe.style.left;
}
</script>
<script type="text/javascript">
function setSize(){
frameResize();
if(window.attachEvent)
window.attachEvent("onresize",frameResize);
else if(window.addEventListener)
window.addEventListener("resize",frameResize,false);
}
</script>
</head>
<body
style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); background-image: url(mountain%20girl%20background.JPG); background-attachment: fixed; background-position: 50%; height: 657px;"
onresize="frameResize()">
<div align="center">
<iframe style="position: absolute; top: 0px; left: 0px; width: 1000px; height: 200px;"
src="banner.html" name="bannerframe" id="bannerframe" allowtransparency="true" frameborder="0"></iframe></div>
<iframe style="position: relative; top: 200px; left: 0px;"
src="menu.html" name="menu" id="menu" allowtransparency="true"
frameborder="0"></iframe>
<iframe style="position: relative; top: 200px; left: 150px; width: 850px; height: 505px;"
src="home.html" name="main" id="main" allowtransparency="true" onload="setSize()" frameborder="0"></iframe>
</body>
</html>
我愿意接受任何其他建议,但我不想使用服务器端脚本。