


js calls the browser printing module to trigger a custom function by clicking the button_javascript skills
May 16, 2016 pm 04:55 PMThe main content of this article:
If you use the print button that comes with the browser, you cannot perform other printing-related operations, such as passing the number of prints, etc. Therefore, you need to retain the browser printing function and assign it to the button you added. You can trigger a custom function when the button is clicked.
<input type="button" class="btnPrint " id="btnPrint" value="Print" />
<iframe frameborder=0 width="100%" height="400px" id="printPDFIframe" src=""<span style="white -space:pre"> </span>></iframe>
<script type="text/javascript">
$("#btnPrint").click(function(){
<pre code_snippet_id= "248441" snippet_file_name="blog_20140321_2_4849863" name="code" class="javascript"><span style="white-space:pre"> </span>printPDF();</pre> }) ; function printPDF(){ if (navigator.appName == 'Microsoft Internet Explorer'){ //Wait until PDF is ready to print if(typeof document.getElementById("printPDFIframe").print == 'undefined'){ setTimeout (function(){printPDF("printPDFIframe");},
1000); }else{ var x = document.getElementById("printPDFIframe"); x.print(); } }else{ PDFIframeLoad(); / / for chrome } } //for Chrome has cancellation/confirmation and cannot be sent directly to the printer function PDFIframeLoad() { debugger; var iframe = document.getElementById("printPDFIframe"); if(iframe.src)
{ var frm = iframe.contentWindow; frm.focus();// focus on contentWindow is needed on some ie versions frm.print(); return false; } }</script>
<pre></pre>
<pre></pre>

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to change the browser to the computer version of the page? Miaodong: How to set the mobile browser to the computer version of the page

How to set the browser to start automatically when booting? How to automatically open the browser when Win11 is started?

Steps to solve the problem that the win7 system browser always automatically pops up the web page

Clear the Google Chrome registry and clean up the remaining residue from uninstalling Google Chrome

Sesame Open Door Official Website Sesame Open Door App Latest Entering Website

The latest version of Sesame Open Door Official Website Entrance gate.io Official Website Link Address Entrance

Reasons and solutions for slow browser network speeds (exploring the reasons for slow browser network speeds)

gate.io sesame door download Chinese tutorial
