Print with WebBrowser from IE
Print Judgment:
if(Factory.Object)//Determination of print settingsFactory.printing.PageSetup (); ElseAlert ("Sorry, I don't support it now!");if(Factory.Object)//the judgment of print previewFactory.printing.Preview (); ElseAlert ("Sorry, I don't support it now!");if(Factory.Object)//the judgment of printing{factory.printing.Print (true); } Else{window.print (); }
<script>
var hkey_root,hkey_path,hkey_key;
hkey_root= "HKEY_CURRENT_USER";
hkey_path= "\\Software\\Microsoft\\Internet explorer\\pagesetup\\";
Function Pagesetup_null () {
Try
{
var wsh=new activexobject ("Wscript.Shell");
hkey_key= "header";
Wsh.regwrite (Hkey_root+hkey_path+hkey_key, "");
hkey_key= "Footer";
Wsh.regwrite (Hkey_root+hkey_path+hkey_key, "");
function Print (a) {
alert (a.id)
Switch (a.id) {
Case "print0":
DOCUMENT.ALL.WEBBROWSER.EXECWB (6, 1)/ /print
break;
Case "print1":
Document.all.WebBrowser.ExecWB (6, 6);//Direct print
break;
Case "Print2":
DOCUMENT.ALL.WEBBROWSER.EXECWB (8, 1)//page set
break;
Case "Print3":
DOCUMENT.ALL.WEBBROWSER.EXECWB (7, 1)// Print preview
break;
}
Document.body.insertAdjacentHTML ("BeforeEnd", "<object id=\" Webbrowser\ "width=0 height=0 \classid=\" clsid : 8856f961-340a-11d0-a96b-00c04fd705a2\ ">");
}
</script>
<input type="Button"runat="Server"Value="Print"onclick="print (this)"Id="print0"/> <input type="Button"runat="Server"Value="Direct Printing"onclick="print (this)"Id="Print1"/> <input type="Button"runat="Server"Value="Print Settings"onclick="print (this)"Id="Print2"/> <input type="Button"runat="Server"Value="Print Preview"onclick="print (this)"Id="Print3"/>
In general, if you are not printing specifically, you need to use a print control such as Loopod
Webbrowse is a simple browser program that supports printing, back, forward, refresh, save As, save and other functions, you can search the online method, here, we say, how to use it to print
First, just like instantiating an object, create it
They are the default is to print the contents of the body, when printing, you can flexibly select the information to be printed, assigned to the body, if you do not want some content to be displayed when printing, you can hide it
<style>
@media print{
Div{display:none}
td,table{
Background:display:none;
}
}
</style>
For example, the printed content has pagination, or other signs, but does not want, it can be hidden away
This page can not be printed at the time of printing, to be hidden away, this time it is possible to put this code in the Div, and then
@media print{
Div{display:none}
You can hide it.
Reference page: http://www.cnblogs.com/oec2003/archive/2007/07/20/825352.html
Printing in jquery