javascript打印没有打印对话框 [英] javascript print without print dialog box

查看:148
本文介绍了javascript打印没有打印对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码段工作正常,但它打开对话框窗口,

The below snippet working fine, but it opening the dialog box window,

但我不想打开打印对话框,

but i dont want to open the print dialog box ,

打印应该没有对话框,

我应该在下面的代码片段中添加什么片段,

what snippet i should add in the below snippet ,

还有一个疑问,我想在DOT矩阵打印机中打印出来,下面的代码片段可以知道吗?

And also one doubt, i want to take print out in DOT Matrix Printer, the below snippet will work know ?

var prtContent = document.getElementById(strid);
var WinPrint =
window.open('','','left=0,top=0');
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
prtContent.innerHTML=strOldOne;

我开发了结算申请,

如果我显示打印对话框,那么它会花费几秒钟来给出打印,看到我完成了更多打印机,
i只有一台打印机,即点阵,当我给出打印命令时,它应该打印BILL没有打开打印对话框,

If i show the print dialog box, then it consume some seconds to give the print , see i done have more printer, i have only one printer ,that is dot matrix, when ever i give print command , then it should print the BILL without open the print dialog box,

推荐答案

这是完全可能的。我在银行工作,并有一个网页,计票员需要在发布交易时自动打印。由于他们整天进行交易,如果他们每次都显示对话框,就会减慢它们的速度。此代码将选择您的默认打印机并直接打印到它,没有对话框。

This is totally possiable. I work in banking and had a webpage that tellers needed to auto print when a transaction was posted. Since they do transactions all day it would slow them down if they had the dialog box display everytime. This code will select your default printer and print directly to it with no dialog box.

<form>
<input type="button" value="Print Page" onClick="window.print()">
</form>


<script language="VBScript">
// THIS VB SCRIP REMOVES THE PRINT DIALOG BOX AND PRINTS TO YOUR DEFAULT PRINTER
Sub window_onunload()
On Error Resume Next
Set WB = nothing
On Error Goto 0
End Sub

Sub Print()
OLECMDID_PRINT = 6
OLECMDEXECOPT_DONTPROMPTUSER = 2
OLECMDEXECOPT_PROMPTUSER = 1


On Error Resume Next

If DA Then
call WB.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER,1)

Else
call WB.IOleCommandTarget.Exec(OLECMDID_PRINT ,OLECMDEXECOPT_DONTPROMPTUSER,"","","")

End If

If Err.Number <> 0 Then
If DA Then 
Alert("Nothing Printed :" & err.number & " : " & err.description)
Else
HandleError()
End if
End If
On Error Goto 0
End Sub

If DA Then
wbvers="8856F961-340A-11D0-A96B-00C04FD705A2"
Else
wbvers="EAB22AC3-30C1-11CF-A7EB-0000C05BAE0B"
End If

document.write "<object ID=""WB"" WIDTH=0 HEIGHT=0 CLASSID=""CLSID:"
document.write wbvers & """> </object>"
</script>

这篇关于javascript打印没有打印对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆