Print in jquery

Source: Internet
Author: User

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

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.