JSP页面打印方法(2008-08-19 16:11:27)
JSP页面打印方法
方法一:
function PrintTable(Id){
var mStr;
mStr = window.document.body.innerHTML ;
var mWindow =
window;
window.document.body.innerHTML =Id.innerHTML;
mWindow.print();
window.document.body.innerHTML = mStr;
}
在页面中要打印
<div id="dy">
.......
</div>
<input type="button"
value="打 印"
onclick="return PrintTable(dy)">
方法二:
with (document)
{//输出样式表表及IE打印控件
write ("<style type=\"text/css\"
media=\"print\">");
write ("
.noPrint{visibility:hidden}");
write ("</style>");
write ("<OBJECT
classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WB
width=0></object>");
}
function doPrintSetup()
{//打印设置
WB.ExecWB(8,1);
}
function doPrintPreview()
{//打印预览
WB.ExecWB(7,1);
}
function doPrint()
{
window.print();
}
function showPrintBar()
{
with (document)
{
write ("<div align=\"center\"
class=\"noprint\">");
write (" <input
type=\"button\" name=\"doBack\" value=\"
<<返回
\" onClick=\"history.go(-1)\">");