我搜到点代码,但显示不正常。有错误。
<script language="javascript">
function window.onload()
{
// -- advanced features
factory.printing.SetMarginMeasure(2) // measure margins in inches
factory.printing.SetPageRange(false, 1, 3) // need pages from 1 to 3
factory.printing.printer = "Epson EPL-N2500 Advanced"
factory.printing.copies = 2
factory.printing.collate = true
factory.printing.paperSize = "A4"
factory.printing.paperSource = "Manual feed"
// -- basic features
factory.printing.header = "居左显示&b居中显示&b居右显示页码,第&p页/共&P页"
factory.printing.footer = "(自定义页脚)"
factory.printing.portrait = false
factory.printing.leftMargin = 0.75
factory.printing.topMargin = 1.5
factory.printing.rightMargin = 0.75
factory.printing.bottomMargin = 1.5
}
function Print(frame) {
factory.printing.Print(true, frame) // print with prompt
}
</script>
........................
<object id="factory" style="display:none" viewastext
classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
codebase="http://www.meadroid.com/scriptx/ScriptX.cab#Version=5,60,0,360"
></object>
<input type=button value="打印本页" onclick="window.onload()">
<input type=button value="页面设置" onclick="document.all.WebBrowser.ExecWB(8,1)">
<input type=button value="打印预览" onclick="document.all.WebBrowser.ExecWB(7,1)"><br>
7 个解决方案
开启了,问题应该不在这个,是代码有问题。哪里有相关代码,或者能帮我看看问题在哪里吗?错误是:1.“对象不支持此属性或方法”,错误2. “document.all.WebBrowser.”为空或不是对象。
<OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0 VIEWASTEXT> </OBJECT>
<input type=button value=打印 onclick="document.all.WebBrowser.ExecWB(6,1)" class="NOPRINT">
<input type=button value=直接打印 onclick="document.all.WebBrowser.ExecWB(6,6)" class="NOPRINT">
<input type=button value=页面设置 onclick="document.all.WebBrowser.ExecWB(8,1)" class="NOPRINT">
<input type=button value=打印预览 onclick="document.all.WebBrowser.ExecWB(7,1)" class="NOPRINT">
你用这个啦,也要开启IE里面ActiveX的.我已经试过啦,可以的,
这个代码我有看到过,也试过了,这个跟我打开“文件/打印“或”文件/页面预览“,差不多呀,我希望是在代码里写好对打印页面的设置,然后直接点击按钮就可以了,你给我的这个我还是要手动设置的呀。
ScriptX控件所需文件ScriptX.cab,
(ScriptX下载地址http://www.meadroid.com/scriptx/freedep.asp )
http://hi.baidu.com/see7di/blog/item/7dca1a238bd3594f93580742.html