2、如果按照固定的行數(shù)分頁,由于每行的高度不一樣,就會(huì)造成有的頁不能填滿,有的卻太滿自動(dòng)分頁了。
ie在打印的時(shí)候不但可以在每頁自動(dòng)添加,還可以自動(dòng)添加表腳,當(dāng)然還可以自動(dòng)判斷長(zhǎng)度分頁,實(shí)現(xiàn)這些都不需要半點(diǎn)腳本。請(qǐng)看這個(gè)例子(使用了內(nèi)置打印控件來預(yù)覽,如果被瀏覽器禁止了需要手工使用打印預(yù)覽功能或者打印出來)
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
function pageSetup(){try{WB.ExecWB(8,1)}catch(e){alert("您的瀏覽器不支持此功能")}}
function preview(){try{WB.ExecWB(7,1)}catch(e){alert("您的瀏覽器不支持此功能")}}
</SCRIPT>
<style>
td,th{border-bottom:1px solid black;width:70px}
thead{display:table-header-group}
tfoot{display:table-footer-group}
</style>
</HEAD>
<BODY>
<OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WB width=0 VIEWASTEXT></OBJECT>
<TABLE cellspacing=0 align=center>
<thead><th> 姓 名 </th><th> 地 址 </th><th> 籍 貫 </th><th>畢業(yè)學(xué)校</th><th> 年 齡 </th><th> 性 別 </th><th> 婚 否 </th></thead>
<tbody align=center>
<SCRIPT LANGUAGE="JavaScript">
<!--
var n=100;
for(var i=0;i<n;i++){
document.write("<tr>");
for(var j=0;j<7;j++)
document.write("<td>"+Math.round(Math.random()*10000)+
(Math.random()>.05?"":"<br>"+Math.round(Math.random()*10000))+
(Math.random()>.02?"":"<br>"+Math.round(Math.random()*10000))+
(Math.random()>.01?"":"<br>"+Math.round(Math.random()*10000))+
"</td>");
document.write("</tr>");
}
//-->
</SCRIPT>
</tbody>
<tfoot><th colspan=7 align=center style="width:100%">這 是 一 個(gè) 測(cè) 試</th></tfoot>
</TABLE>
</BODY>
<SCRIPT LANGUAGE="JavaScript">
preview();
</SCRIPT>
</HTML>
例子中特意使用腳本構(gòu)造了隨機(jī)高度的行。 回復(fù)