In IE, VBScript is used without prompting the code to be printed directly.

Source: Internet
Author: User

First, add the webbrowser object to the HTML page:
<Object classid = "CLSID: 8856f961-340a-11d0-a96b-00c04fd705a2" Height = 0 id = WB name = WB width = 0> </Object>
Then, use the following Code Print:
<Script language = "VBScript">
Sub printvb ()
Wb.exe CWB 6, 2, 3
End sub
</SCRIPT>
The key code wb.exe CWB 6, 2, 3 can be printed directly in VBScript mode without prompting, But it is strange that the same parameter is used. In JavaScript mode, ie will still pop up the Print dialog window, maybe it is because VBScript is developed by Microsoft for IE, while Javascript is an outsider after all :)
Find another comprehensive example, as shown below:
6 = olecmdid_print
2 = olecmdexecopt_dontpromptuser,
2 + 1 = print_waitforcompletion + print_dontbotheruser
WB. execwb 6, 2, 3, 0
<HTML>
<Head>
<Object ID = "WB" width = "0" Height = "0" classid = "CLSID: 8856f961-340a-11d0-a96b-00c04fd705a2"> </Object>
<Script language = "VBScript">
Sub window_onunload
On Error resume next
Set WB = nothing
End sub
Sub vbprintpage (x, y, z)
Olecmdid_print = 6
Olecmdexecopt_dodefault = 0
Olecmdexecopt_promptuser = 1
Olecmdexecopt_dontpromptuser = 2
On Error resume next
WB. execwb X, Y, Z, 0
End sub
</SCRIPT>
</Head>
<Body>
<Table border = 1> <tr> <TD>
<Input type = "button" value = "print" onclick = "vbprintpage 6, 2, 3"> <br>
<Input type = "button" value = "preview" onclick = "vbprintpage 7, 1, 0"> <br>
<Input type = "button" value = "Page setup" onclick = "vbprintpage 8, 1, 0"> <br>
</TD>
<TD bgcolor = "green"> Print Test
</TD> </tr> </table>
</Body>
</Html>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.