Webpage WB. execwb control printing method

Source: Internet
Author: User
Webpage WB. execwb control printing method

Code:

<Table width = "100%" cellpadding = "1" onmouseover = "KPR. style. Display =''; ">
<Tr>
<TD width = "100%" Height = "25" colspan = "3"> <script language = "JavaScript">

Function printsetup (){
// Print page settings
Wb.exe CWB (8, 1 );
}
Function printpreview (){
// Print the Page Preview

Wb.exe CWB (7,1 );
}

Function printit ()
{
If (confirm ('Are you sure you want to print? ')){

Wb.exe CWB (6, 6)
}
}
</SCRIPT>
<Object classid = "CLSID: 8856f961-340a-11d0-a96b-00c04fd705a2" Height = 0 id = WB name = WB width = 3> </Object>
<Div id = "KPR">
<Input class = "ept" type = button name = button _ print value = "print" onclick = "KPR. style. display = 'none'; javascript: printit (); ">
<Input class = "ept" type = button name = button _ setup value = "print page settings" onclick = "javascript: printsetup ();">
<Input class = "IPT" type = button name = button_show value = "print preview" onclick = "KPR. style. Display = 'none'; javascript: printpreview ();">
<Input class = "ept" type = button name = button _ FH value = "close" onclick = "javascript: window. Close ();"> </TD>
</Div> </tr>
</Table>

Parameter Method:

WB. execwb (4, 1)

4. 1 save the webpage
4, 2 Save the webpage (you can rename it)
6, 1 print directly
6, 2 print directly
7, 1 print preview
7, 2 print and preview
8, 1 select parameters
8, 2 select parameters
10, 1 view page properties
10, 2 view page properties
Select All 17,1
Select All 17,2
Reload the current page
Reload the current page

<Object classid = CLSID: 8856f961-340a-11d0-a96b-00c04fd705a2 Height = 0 id = webbrowser width = 0> </Object>
<Input name = button onclick = Document. All. webbrowser. execwb (1,1) type = button value = open>
<Input name = button onclick = Document. All. webbrowser. execwb (2, 1) type = button value = close all>
<Input name = button onclick = Document. All. webbrowser. execwb (4,1) type = button value = Save As>
<Input name = button onclick = Document. All. webbrowser. execwb (6, 1) type = button value = print>
<Input name = button onclick = Document. All. webbrowser. execwb (6, 6) type = button value = print directly>
<Input name = button onclick = Document. All. webbrowser. execwb (8, 1) type = button value = page Settings>
<Input name = button onclick = Document. All. webbrowser. execwb (10, 1) type = button value = attribute>
<Input name = button onclick = Document. All. webbrowser. execwb (17,1) type = button value = select all>
<Input name = button onclick = Document. All. webbrowser. execwb (22, 1) type = button value = Refresh>
<Input name = button onclick = Document. All. webbrowser. execwb (45, 1) type = button value = close>

 

Http://hi.baidu.com/plehwh/blog/item/64f9c839ef8e58e115cecbc8.html/cmtid/b932fe289334ea355343c1bf

 

 

// ================================================ ========================================================== ==============

Webbrowser object printing settings

Webbrowser object <Object ID = "webbrowser" width = 0 Height = 0 classid = "CLSID: 8856f961-340a-11d0-a96b-00c04fd705a2">
</Object>
<Input type = "button" name = "button" value = "Close Window" onclick = "document. all. webbrowser. execwb (45,1) "> parameter: webbrowser. execwb () Open
Webbrowser. execwb () Close all existing IE Windows and open a new window
Webbrowser. execwb () Save the webpage
Webbrowser. execwb (6, 1) print
Webbrowser. execwb (7,1) print preview
Webbrowser. execwb (8, 1) print page settings
Webbrowser. execwb (10, 1) view page properties
Webbrowser. execwb (15, 1) undo
Select All webbrowser. execwb (17,1)
Webbrowser. execwb (22, 1) Refresh
Webbrowser. execwb () Close form no prompt
<! -- Ie5.5 or above -->
<Object ID = webbrowser classid = CLSID: 8856f961-340a-11d0-a96b-00c04fd705a2 Height = 0 width = 0> </Object>
<Input type = button value = print onclick = Document. All. webbrowser. execwb (6, 1)>
<Input type = button value = print onclick = Document. All. webbrowser. execwb (6, 6)>
<Input type = button value = page setting onclick = Document. All. webbrowser. execwb (8, 1)>
<Input type = button value = print preview onclick = document. all. webbrowser. execwb (7,1)> <input type = button value = Enable onclick = document. all. webbrowser. execwb (1, 1)>
<Input type = button value = save as onclick = Document. All. webbrowser. execwb (4,1)>
<Input type = button value = attribute onclick = Document. All. webbrowser. execwb (10, 1)>
<Input type = button value = select all onclick = Document. All. webbrowser. execwb (17,1)>
<Input type = button value = Refresh onclick = Document. All. webbrowser. execwb (22, 1)>
<Input type = button value = Close Window onclick = Document. All. webbrowser. execwb (45, 1)> controls the margin of the vertical and horizontal pages.
(1) <SCRIPT defer>
Function setprintsettings (){
// -- Advanced features
Factory. Printing. setmarginmeasure (2) // measure margins in inches
Factory. setpagerange (false, 1, 3) // need pages from 1 to 3
Factory. Printing. Printer = "HP Deskjet 870c"
Factory. Printing. Copies = 2
Factory. Printing. collate = true
Factory. Printing. papersize = "A4"
Factory. Printing. papersource = "manual feed" // -- Basic Features
Factory. Printing. header = "this is meadco"
Factory. Printing. footer = "advanced printing by scriptx"
Factory. Printing. Portrait = false
Factory. Printing. leftmargin = 1.0
Factory. Printing. topmargin = 1.0
Factory. Printing. rightmargin = 1.0
Factory. Printing. bottommargin = 1.0
}
</SCRIPT> (2)
<Script language = "JavaScript">
Function printsetup (){
// Print page settings
Wb.exe CWB (8, 1 );
}
Function printpreview (){
// Print the Page Preview

Wb.exe CWB (7,1 );


} Function printit ()
{
If (confirm ('Are you sure you want to print? ')){
Wb.exe CWB (6, 6)
}
}
</SCRIPT>
</Head>
<Body>
<Object classid = "CLSID: 8856f961-340a-11d0-a96b-00c04fd705a2" Height = 0 id = WB name = WB width = 0> </Object>
<Input type = button name = button_print value = "print" onclick = "javascript: printit ()">
<Input type = button name = button_setup value = "print page settings" <input type = button name = button_show value = "print preview" <input type = button name = button_fh value =" disable "onclick =" javascript: window. close (); "> ------------------------------------------------
There are other usage examples of this component:
Webbrowser. execwb () Open
Web. execwb () Close all existing IE Windows and open a new window
Web. execwb () save Web Page
Web. execwb (6, 1) Printing
Web. execwb (7,1) print and preview
Web. execwb (8, 1) Printing page settings
Web. execwb () view page properties
Web. execwb () seems to be undo, to be confirmed
Select all web. execwb ()
Web. execwb (22, 1) Refresh
Web. execwb (45, 1) Close the form without prompting 2. Print by PAGE
<HTML>
<Head>
<Style>
P {page-break-after: Always}
</Style>
</Head>
<Body>
<% While not Rs. EOF %>
<P> <% = RS (0) %> </P>
<% Rs. movenext %>
<% Wend %>
</Body>
</Html> 3. How to remove the path at the bottom of the page and the page number at the top of the page when printing an ASP page
(1) The IE File-> page settings-> the content in the header and footer is removed, and the print is not displayed.
(2) <HTML>
<Head>
<Title> new document </title>
<Meta name = "generator" content = "editplus">
<Meta name = "author" content = "YC">
<Script language = "VBScript">
Dim hkey_root, hkey_path, hkey_key
Hkey_root = "HKEY_CURRENT_USER"
Hkey_path = "/software/Microsoft/Internet Explorer/pagesetup"
'// Set the page header and footer to be blank
Function pagesetup_null ()
On Error resume next
Set regwsh = Createobject ("wscript. Shell ")
Hkey_key = "/Header"
Regwsh. regwrite hkey_root + hkey_path + hkey_key ,""
Hkey_key = "/footer"
Regwsh. regwrite hkey_root + hkey_path + hkey_key ,""
End Function
'// Set the page header and footer to the default value.
Function pagesetup_default ()
On Error resume next
Set regwsh = Createobject ("wscript. Shell ")
Hkey_key = "/Header"
Regwsh. regwrite hkey_root + hkey_path + hkey_key, "& W & B page number, & P/& P"
Hkey_key = "/footer"
Regwsh. regwrite hkey_root + hkey_path + hkey_key, "& U & B & D"
End Function
</SCRIPT>
</Head> <body>
<Br/>
<Br/>
<Br/>
<Br/>
<Br/>
<Br/> <p align = center>
<Input type = "button" value = "Clear page number" <input type = "button" value = "Restore page?" onclick = pagesetup_default ()> <br/> </P>
</Body>
</Html>
4. Floating frame Printing
<Script language = JavaScript>
Function button1 _{
VaR odoc=w.w.iframe1.doc ument;
VaR r = odoc. Body. createTextRange ();
VaR stxt=r.html text;
Alert (stxt)
VaR pwin = Window. Open ("", "print ");
Pwin.doc ument. Write (stxt );
Pwin. Print ();
}
</SCRIPT>
4. Use the filesystem component to implement specific local printing in Web Applications
<Script language = VBScript>
Function print_onclick // print the Function
Dim label
Label = Document. printinfo. Label. Value // obtain HTML page data
Set objfs = Createobject ("scripting. FileSystemObject") // create an instance of the filesystem Component Object
Set objprinter = objfs. createtextfile ("LPT1:", true) // establish a connection with the printer
Objprinter. writeline ("__________________________________") // output printed content
Objprinter. writeline ("| ")
Objprinter. writeline ("| the data you printed is:" & label & "| ")
Objprinter. writeline ("| ")
Objprinter. writeline ("| _________________________________ | ")
Objprinter. Close // disconnect from the printer
Set objprinter = nothing
Set objfs = nothing // disable the filesystem Component Object
End Function
</SCRIPT>
Server script:
<% .........
Set conn = server. Createobject ("ADODB. Connection ")
Conn. Open "DSN = Name; uid = xxxx; Pwd = xxxx ;"
Set rs = server. Createobject ("ADODB. recordset ")
Rs. Open ("select ......"), Conn, 1, 1
.......... %> // Interact with the database
HTML page encoding:
<HTML>
.........
<Form ID = printinfo name = "printinfo">
<Input type = "button" value = "Print>" id = Print name = print> // call the print function
<Input type = hidden id = text1 name = label value = <% = ......... %> // Save data sent from the server
.........
</Html>

Http://zjland.blog.51cto.com/289954/125377/

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.