把要打印的部分放在<div id="printsection"></div>中
然后使用下面的函数
function printsection()
{
var aaa = document.all.printsection.innerHTML;
var ddd = document.body.innerHTML;
document.body.innerHTML = aaa;
window.print();
document.body.innerHTML = ddd;
return false;
}
用控件,先设置一下
<object id="WebBrowser" width=0 height=0 classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">
</object>
<input name="printformview" type="button" value="打印机设置" onClick=document.all.WebBrowser.ExecWB(6,1) class="button">
<input name="printform2" type="button" value="页面设置" onClick=document.all.WebBrowser.ExecWB(8,1) class="button">
<input name="printform" type="button" value="直接打印" onClick=document.all.WebBrowser.ExecWB(6,6) class="button">