方法一:
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=“打 印” οnclick=“return PrintTable(dy)”
在页面中要打印
斤斤计较
方法二:
with (document)
{//输出样式表表及IE打印控件
write ("<style type=“text/css” media=“print”>");
write (" .noPrint{visibility:hidden}");
write ("");
write ("");
}
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)”>");
write (" <input type=“button” name=“doPrintPreview” onClick=“WB.ExecWB(8,1)” value=“打印设置”>");
write (" <input type=“button” name=“doPrint” value=" 打印>> " onClick=“doPrint()”>");
write ("")
}
}
----------------print.js end------------
页面中使用时:
然后再需要输出打印按钮时:
方法三:
打印前把按钮隐藏
方法四:
给不打印的区加这个CSS就可以了,在页面上能看见但打印的时候看不到!
方法五:
利用脚本控制打印,可以采用如下方法:
1、execCommand()方法
Print 打开打印对话框以便用户可以打印当前页
即document.execCommand(‘Print’);
2、window.print()
3、
方法六:
<%@ page contentType=“text/html; charset=GBK”%>
<%
String url="#"
%>
<jsp:include page="<%=url%>" />