JavaScript calls browser print function example Analysis _javascript tips

Source: Internet
Author: User

The example in this article describes the way JavaScript calls the browser print feature. Share to everyone for your reference. Specifically as follows:

1. Universal type, support ie,firefox,chrome ...

Copy Code code as follows:
Window.print ();

2. Only support IE print:

<script>
var print=function () {
/**
 * WEBBROWSER.EXECWB (1,1) opens
 * WEB.EXECWB (2,1) closes 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 c11/>* WEB.EXECWB (10,1) view page Properties
 * WEB.EXECWB (15,1) appears to be revoked, pending confirmation
 * WEB.EXECWB (17,1) All
 * WEB.EXECWB (22,1) Refresh
 * WEB.EXECWB (45,1) Close form no hint 
 * *
document.getElementById (' printer '). EXECWB (6,1);
}
</script>
<object classid= "CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" id= "printer"
  height= "0 "width=" 0 "></OBJECT>
<button onclick=" print (); " > Printing </button>

3. Control the print display area and pagination style:

. noprint {
  display:none
}
. nextpage {
  page-break-after:always;
}

I hope this article will help you with your JavaScript programming.

Related Article

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.