网页设计:怎么让frame的高度自适应??

来源:百度知道 编辑:UC知道 时间:2024/05/23 21:46:22
所有的页面我都是用DIV+CSS做的。
好了我打开index.html看到的是一个压缩的网页,做显示了屏幕大小1024*768的固定大小。不会想新浪这些一打开有很长很长。。
代码如下:
<frameset rows="80,*,80 cols="*" framespacing="0" frameborder="no" border="0">
<frame src="head.html" name="topFrame" scrolling="No" noresize="noresize" id="topFrame" title="topFrame" />
<frame src="main.html" name="mainFrame" id="mainFrame" title="mainFrame" />
<frame src="foot.html" name="bottomFrame" scrolling="No" noresize="noresize" id="bottomFrame" title="bottomFrame" />
</frameset>

求解,附上代码,或其他实现方式都可以。。。。
QQ232172249

可以用jQuery控制

// 获取窗口的高度
var win_h = $(window).height();
$(".xx").height(win_h);

// 窗口变化事改变高度
$(window).resize(function(event) {
// 获取窗口的高度
var win_h = $(window).height();

$(".xx").height(win_h);
}

高度自适应可以用Javascript

你每个iframe为一个单独的页面,只需在每个单独的页面中<head>与</head>之间加入如下代码即可实现firame高度的自适应:
<script type="text/javascript">
function setWindowSize(){ //iframe自动本窗口高度
try{
var thiswin = window.parent.document.getElementById(window.name);
if(window.document.body.scrollWidth-thiswin.offsetWidth>6){
document.body.style.overflowX="auto";
thiswin.height=window.document.body.scrollHeight+20;
thiswin.width=window.document.body.scrollWidth+20;
}else{
document.body.style.overflowX="hidden";
thiswin.heig