jquery Implementation Area printing function code detailed _jquery

Source: Internet
Author: User

Using CSS to control the print style, you need to set the style media= "print" and set the style display property of elements that do not need to be printed on the page to none. As in demo, I set the header footer and other elements that don't need to be printed as follows:

<style type= "text/css" media= "print" > 
#header,. Top_title, #jqprint, #footer, #cssprint H3{display:none} 

Using jquery to print Plug-ins printarea.js

$ (function () { 
$ ("#print_btn"). Click (function () { 
$ ("#my_area"). PrintArea (); 
 

There is a piece of code in the demo:

<p><a href= "#" id= "PRINT_BTN" > click here to print >></a></p> 
<div id= "My_area" > 
... Print Area ...<br/> 

When you click the Print button, the Printarea.js plug-in is invoked. The plug-in also provides some parameters to configure, using the method: $ (Element). PrintArea (option).

Parameter settings:

1, Mode: Model, when clicked on the Print button trigger mode, the default is IFRAME, when set to popup will open a new window page print.

2, Poptitle: Set the title of the new open window, the default is empty.

3, Popclose: The completion of the printing window is closed, the default is False.

Ps:ie Browser Print page to remove the header and Footer URL method: File-> page settings, the page and footer of the input box empty.

The above is a small set of jquery to introduce the implementation of regional printing function code detailed, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

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.