日期:2014-05-18  浏览次数:20470 次

table绝对高度
我给一个table的高度为相对高度,例如100%,
或者干脆就没有设定高度,table里的内容把table的高度给撑起来了。
请问我在运行时如何得到这个table的绝对高度。
谢谢

------解决方案--------------------
HTML code

<table id="tb1">
...
</table>
<input   type=button   onclick="alert(document.all.tb1.offsetHeight)">

------解决方案--------------------
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
function showtable()
{
var table1= document.getElementById("table1");
alert("宽:"+table1.clientWidth);
alert("高:"+table1.clientHeight);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<table id="table1" runat="server"><tr><td> <asp:Wizard ID="Wizard1" runat="server">
<WizardSteps>
<asp:WizardStep ID="WizardStep1" runat="server" Title="Step 1">
</asp:WizardStep>
<asp:WizardStep ID="WizardStep2" runat="server" Title="Step 2">
</asp:WizardStep>
</WizardSteps>
</asp:Wizard></td></tr></table>
<input id="Button1" type="button" value="点击我显示table的宽和高" onclick="showtable()" />


</form>
</body>
------解决方案--------------------
http://www.cftea.com/c/2006/12/PCTKER6T0V62S854.asp