1.先要加载打印的object ,
<OBJECT id="factory" codeBase="../../ScriptX.cab" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" VIEWASTEXT><OBJECT >
<object id="WebBrowser" classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height="0" width="0" VIEWASTEXT><OBJECT >
2.如果是ie6,那么可以用scriptx.cab打印,
3如果是ie7和ie8,还有其他的浏览器,就只可以用WebBrowser,让用户自己设置
//factory设置 function SetPrint() {
//设置页头内容 factory.printing.header = "";
//设置页脚内容 factory.printing.footer = "";
//设置打印的版式,false为横版,true为竖版 factory.printing.portrait = true;
//设置上下左右的间距
factory.printing.leftMargin =8
factory.printing.topMargin = 20
factory.printing.rightMargin =8
factory.printing.bottomMargin = 0.0
}
//打印设置
function PageSetup(){
try{
SetPrint(); WebBrowser.ExecWB(8,1);
} catch(e){
WebBrowser.ExecWB(8,1);
}
}
//打印预览
function ShowPage(){
try{
SetPrint();
WebBrowser.ExecWB(7,1);
} catch(e){
WebBrowser.ExecWB(7,1);
}
}
//打印 function PrintPage(){
try{
SetPrint();
WebBrowser.ExecWB(6,1);
} catch(e){
WebBrowser.ExecWB(6,1);
} }