喜悦国际村 » XML/HTML/CSS/Js » 用javascript 打印的表格现在断线,大侠帮忙。

页: [1]
Tonkin2004-11-25 03:16 AM
用javascript 打印的表格现在断线,大侠帮忙。

表格行数在一页内可以,但是要是很多页,打印的表格会出现断线,很不好看,有什么好的解决方法吗?

看了二个例子:
P {page-break-after: always}

<br page-break-after: always>
不太会使呀

<html>
<head>
<title>print</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
.tdp
{
    border-bottom: 1 solid #000000;
    border-left:  1 solid #000000;
    border-right:  0 solid #ffffff;
    border-top: 0 solid #ffffff;
}
.tabp
{
    border-color: #000000 #000000 #000000 #000000;
    border-style: solid;
    border-top-width: 2px;
    border-right-width: 2px;
    border-bottom-width: 1px;
    border-left-width: 1px;
}
@media print {.no_print{display: none;}}
</style>
<script language="VBScript">
dim hkey_root,hkey_path,hkey_key
hkey_root="HKEY_CURRENT_USER"
hkey_path="\Software\Microsoft\Internet Explorer\PageSetup"
function pagesetup_null()
on error resume next
Set RegWsh = CreateObject("WScript.Shell")
hkey_key="\header"
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,""
hkey_key="\footer"
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,""
end function
</script>
<script language="JavaScript">
function print_report(){
  if (confirm('确定打印吗?')) {
  self.print();
  }
}
</script>
</head>

<body leftmargin="0" topmargin="0" onLoad="pagesetup_null()">
<table width="100%" border="0" cellpadding="0">
  <tr>
    <td> <form name="form1" method="post">
        <table border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td>&nbsp;</td>
            <td width="51%"><div align="right"> </div></td>
          </tr>
          <tr>
            <td colspan="2"> <table border="0" class="tabp" align="center" cellpadding="2" cellspacing="0" bgcolor="#000000">

<?
for($i=0;$i<=120;$i++){
  ?>
                  <tr>
                  <td class="tdp"  bgcolor='#FFFFFF'>&nbsp;</td>
                  <td class="tdp"  bgcolor='#FFFFFF'>&nbsp;</td></td>
                  <td class="tdp"  bgcolor='#FFFFFF'>&nbsp;</td>
                  <td class="tdp"  bgcolor='#FFFFFF'>&nbsp;</td>
                  <td class="tdp" bgcolor='#FFFFFF'>&nbsp;</td>
                  <td class="tdp"  bgcolor='#FFFFFF'>&nbsp;</td>
                  <td class="tdp"  bgcolor='#FFFFFF'>&nbsp;</td>
                  <td class="tdp"  bgcolor='#FFFFFF'>&nbsp;</td>
                  <td class="tdp"  bgcolor='#FFFFFF'>&nbsp;</td>
                  <td class="tdp"  bgcolor='#FFFFFF'>&nbsp;</td>
                  <td class="tdp"  bgcolor='#FFFFFF'>&nbsp;</td>
                  <td class="tdp"  bgcolor='#FFFFFF'>&nbsp;</td>
                                  <td class="tdp"  bgcolor='#FFFFFF'>&nbsp;</td>
                  <td class="tdp"  bgcolor='#FFFFFF'>&nbsp;</td>
                </tr>
  <?
}
?>

              </table></td>
          </tr>
          <tr>
            <td colspan="2">&nbsp;</td>
          </tr>
        </table>
      </form></td>
  </tr>
  <tr>
    <td height="19"><center><input type=button name="printsub" value=" 打印 " onclick="print_report();"  class="no_print">
      </center>

</td>
  </tr>
</table>

</body>
</html>


查看完整版本: 用javascript 打印的表格现在断线,大侠帮忙。


Powered by Discuz! Archiver 6.1.0  © 2001-2006 Comsenz Inc.
Processed in 0.006497 second(s), 2 queries