<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head><body>
<div>
<div id=main style="float:left;width:600px; height:600px; background:#ccc;">
动态生成的内容,高度不定
</div>
<div id=rightbar style="float:right;width:300px; background:red;">
右边栏,内容比main少
</div>
</div>
<script language="javascript">
window.onload=function(){document.getElementById("rightbar").style.height=document.getElementById("main").currentStyle.height;};
</script>
</html>
window.onload = function(){
document.getElementById("rightbar").style.height = document.getElementById("main").offsetHeight;
};
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head><body>
<div>
<div id=main style="float:left;width:600px; background:#ccc;">
动态生成的内容,高度不定 <br>
动态生成的内容,高度不定 <br>
动态生成的内容,高度不定 <br>
动态生成的内容,高度不定 <br>
动态生成的内容,高度不定 <br>
动态生成的内容,高度不定 <br> </div>
<div id=rightbar style="float:right;width:300px; background:red;">
右边栏,内容比main少
</div>
</div>
<script language="javascript">
window.onload=function(){document.getElementById("rightbar").style.height=document.getElementById("main").currentStyle.height;};
</script>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head><body>
<div>
<div id=main style="float:left;width:600px; background:#ccc;">
动态生成的内容,高度不定 <br>
动态生成的内容,高度不定 <br>
动态生成的内容,高度不定 <br>
动态生成的内容,高度不定 <br>
动态生成的内容,高度不定 <br>
动态生成的内容,高度不定 <br> </div>
<div id=rightbar style="float:right;width:300px; background:red;">
右边栏,内容比main少
</div>
</div>
<script language="javascript">
window.onload=function(){
var m = document.getElementById('main');
var r = document.getElementById('rightbar');
m.offsetHeight>r.offsetHeight ? r.style.height = m.offsetHeight+'px' : m.style.height = r.offsetHeight+'px';
};
</script>
</html>
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title> <SCRIPT LANGUAGE="JavaScript" src="http://code.jquery.com/jquery-latest.js"></SCRIPT>
<Script>
</script>
</head><body>
<div>
<div id=main style="float:left;width:600px; background:#ccc;">
动态生成的内容,高度不定 <br>
动态生成的内容,高度不定 <br>
动态生成的内容,高度不定 <br>
动态生成的内容,高度不定 <br>
动态生成的内容,高度不定 <br>
动态生成的内容,高度不定 <br> </div>
<div id=rightbar style="float:right;width:300px; background:red; display:block">
右边栏,内容比main少
</div>
</div>
<script language="javascript">
window.onload=function(){
var he= $('#main').height();$('#rightbar').height(he);};
</script>
</html>
上面这个代码,我自己已经测试过了.