摘要:友善列印做法
<script type="text/javascript">
function previewScreen(block)
{
var value = block.innerHTML;
var printPage = window.open("","printPage","");
printPage.document.open();
printPage.document.write("<OBJECT classid='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2'
height=0 id=wc name=wc width=0>友善列印</OBJECT>");
printPage.document.write("<HTML><head></head><BODY onload='javascript:window.print();window.close();'>");
printPage.document.write("<PRE>");
printPage.document.write(value);
printPage.document.write("</PRE>");
printPage.document.close("</BODY></HTML>");
}
</script>
<a onkeypress="previewScreen(PrintDiv1)" onclick="previewScreen(PrintDiv1)" style="text-decoration:none" target="_blank">
<img src="images/icon_13_1.gif" width="90" height="49" alt="友善列印">
</a>
//需要列印的內容包在div中
<div id="PrintDiv1">
<table>
<tr><td class="TFont12" align ="left" >
<asp:Literal id="Lite1" runat ="server" ></asp:Literal>
</td>
</tr>
</table>
</div>
資料來源: http://jackchu0936.blogspot.tw/2011/12/blog-post.html