The main content of this article:
If you use the Print button from your browser, you cannot perform the rest of the print-related operations, such as the number of times you pass the print. So you need to keep and give the browser's printed functionality to the buttons you add, and you can trigger the custom function while clicking the button.
Copy Code code as follows:
<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>
Copy Code code as follows:
<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 cancel/confirm, cannot send directly to printer function Pdfiframeload () {debugger; var iframe = document.getElementById ("Printpdfiframe"); if (IFRAME.SRC)
{var frm = Iframe.contentwindow frm.focus ()//focus on Contentwindow are needed on some IE versions frm.print (); False }}</script>
<pre></pre>
<pre></pre>