WebBrowser is a built-in browser control in IE, and no user download is required.
1. WebBrowser control
<object ID='WebBrowser' WIDTH=0 HEIGHT=0 CLASSID='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2'></object>
2. Methods of WebBrowder control //Print
WebBrowser1.ExecWB(6,1);
//Print settings
WebBrowser1.ExecWB(8,1);
//Print preview
WebBrowser1.ExecWB(7,1);
There are other uses of this component, listed as follows:
WebBrowser.ExecWB(1,1) Open Web.ExecWB(2,1) Close all IE windows now and open a new window Web.ExecWB(4,1)
Save web page Web.ExecWB(6,1) Print Web.ExecWB(7,1) Print preview Web.ExecWB(8,1)
Print page settings Web.ExecWB(10,1)
View page properties Web.ExecWB(15,1)
It seems to be cancelled, and it is to be confirmed Web.ExecWB(17,1)
Select all Web.ExecWB(22,1) Refresh Web.ExecWB(45,1)
Close the form and there is no prompt, but printing will print the entire page. If there is anything in the page, we will print it out. Sometimes we only need to print the data table. At this time, we have to write a style:
Hide the parts you don't want to print: Style content: <style type="text/css" media=print> .noprint{display : none } </style>
Then use the style: <p>No printing required</p>
The code is as follows:
The code copy is as follows:
<script language="javascript"> function printsetup(){ // Print page settings wb.execwb(8,1); } function printpreview(){ // Print page preview
wb.execwb(7,1);
}
function printit() { if (confirm('Are you sure to print?')) { wb.execwb(6,6) } } } </script>
<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" onclick="javascript:printsetup();"> <input type=button name=button_show value="Print preview" onclick="javascript:printpreview();">