Web|web print WebBrowser is a built-in browser control for IE, without user downloads. This document discusses the WebBrowser control technical content for the IE6.0 version. Other versions of IE should also be supported. Its related technical requirements are: the production of printed documents, page settings, printing operations, such as the implementation of several links. This article takes the ASP as an example, but he can easily migrate to other web technologies.
One, WebBrowser control
<object id= ' WebBrowser ' width=0 height=0 classid= ' clsid:8856f961-340a-11d0-a96b-00c04fd705a2 ' ></object >
Methods of Webbrowder Control
Print
WEBBROWSER1.EXECWB (6,1);
Print settings
WEBBROWSER1.EXECWB (8,1);
Print Preview
WEBBROWSER1.EXECWB (7,1);
Third, the implementation of printing settings, printing data generation, print preview, and printing.
To achieve printing settings, print data generation, print preview, and print I generally do so, if the query results in a.asp, then put the print settings in a.asp, Print Preview, print three buttons.
Click the Print Setup button to perform WEBBROWSER1.EXECWB (8,1) in JS to open the Print Setup window.
Clicking the Print Preview button opens a b.asp, regenerates the print data in b.asp, and then automatically executes WEBBROWSER1.EXECWB (7,1) in b.asp to open the user preview interface.
Clicking the Print button also turns on b.asp, regenerates the print data in b.asp, and automatically executes WEBBROWSER1.EXECWB (6,1) in b.asp to automatically print the data.
Four, code
A.asp the program that invokes the data is not given. Code that gives only a few buttons:
<input type= "button" Name= "Mprint" value= "print" onclick= "exeprint ();" >
<input type= "button" Name= "Mpreview" value= "Print Preview" onclick= "Exepreview ();" >
<input type= "button" Name= "msetting" value= "Print Settings" onclick= "exesetting ();" >
<object id= ' WebBrowser ' width=0 height=0 classid= ' clsid:8856f961-340a-11d0-a96b-00c04fd705a2 ' ></object >
<script language= ' JavaScript ' >
function Exeprint ()
{
liu= window.open (' b.asp?do=1 ', ' _blank ', ' left=2000,top=2000,fullscreen=3 ');
}
function Exepreview ()
{
window.open (' b.asp?do=2 ', ' _blank ', ' left=2000,top=2000,fullscreen=3 ');
}
function exesetting ()
{
WEBBROWSER.EXECWB (8,1);
}
</script>
The code for printing settings in code is simple and easy to understand. Print Preview and Print buttons need to tell b.asp what we are going to do is print or print preview. In addition, you pass the query string past. Of course, the Web master can try other methods to avoid repeatedly heavy server data, of course, beginners can only through multiple queries, sacrificing performance to solve the printing.
Suppose in this example a.asp the b.asp by passing a query string, the data is loaded back in b.asp. Showing the data on the Web page after loading the data here needs to know how many (PageSize) each page will display. Display a <p style= ' page-break-before:always ' after each display pagesize bar; > This statement is equivalent to a page break, which is when you encounter this page break when you print or preview it, forcing pagination. Generally we can do this:
<table>
???
</table>
<p style= ' page-break-before:always; ' >
<table>
???
</table>
<p style= ' page-break-before:always; ' >
......
<table>
???
</table>
<p style= ' page-break-before:always; ' >
After the data is displayed, the preview or print is performed according to the user's instruction (judging the value of the parameter do).
If it is a preview, execute the following code:
WEBBROWSER.EXECWB (7,1);
Window.opener=null;
Window.close ();
If it is printed, execute:
WEBBROWSER.EXECWB (6,1);
Window.opener=null;
Window.close ();