The ultimate cheat of Web printing (finishing)

Source: Internet
Author: User
Tags object visibility
web| Printing

Usually in the Web printing need scriptx.cab, here is the same, so the principle is the same, here will be detailed, how to control the printing problem.

There are 2 required files for printing:

1: Configuration file: Setting.js
2: Display files: print.js

Setting.js is as follows:

document.write ("<object id=\" factory\ "style=\" display:none\ "Viewastext classid=\" clsid : 1663ed61-23eb-11d2-b92f-008048fdd814\ "codebase=\" images/events/scriptx.cab#version=5,60,0,360\ "></ Object> ");
function Printers () {
Agree = confirm (' OK print? ');
if (agree) {
if (agree)
{
noprinter.style.visibility= ' hidden ';
Factory.printing.Print ();}
else noprinter.style.visibility= ' visible ';
}
}

Factory.printing.header = ""
Factory.printing.footer = ""
Factory.printing.leftMargin = 0.75
Factory.printing.topMargin = 0.75
Factory.printing.rightMargin = 0.75
Factory.printing.bottomMargin = 0.75

The file print.js appears as follows:

document.write (' <style media= ' print ' > @media print {. Noprint{display:none}}} </ Style> '); The
/////////////////////////////////~~ controls the style of not displaying buttons when printing, and you only need to reference the style where the page does not need to be printed
document.write (' <div id=noprinter name=noprinter align=right style= ' visibility:visible ' class= ' noprint ' >< br>  ');
document.write (' <input type=button Class=button value= off name= "Bfq" id= "Bfq" onclick=\ "javascript\: Window.close ()/">");
document.write (' <input  type= ' button "value=" Print Setup "onclick=\" Factory.printing.PageSetup () \ ">");
document.write (' <input type= "button" value= "Print Preview" onclick=\ "Factory.printing.Preview () \" > ");
document.write (' <input type=button name=button3 value= ' print ' >    </div> ');


When using the print function, just include the file 2 files in the page where the Print button is placed, the code is as follows:
<script src= ". /inc/print/printer.js "></script>
<script src= ". /inc/print/printers.js "></script>



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.