How to print particular div?
If you have to print particular div as per the client’s requirement then you have to call “ClickHereToPrint” function which is defined below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
<!DOCTYPE html> <html> <head> <script type = 'text/javascript'> function ClickHereToPrint() { try { var oIframe = document.getElementById('ifrmPrint'); var oContent = document.getElementById('divToPrint').innerHTML; var oDoc = (oIframe.contentWindow || oIframe.contentDocument); if (oDoc.document) oDoc = oDoc.document; oDoc.write('<head><title>title</title>'); oDoc.write('</head><body onload=\'this.focus(); this.print();\'>'); oDoc.write(oContent + '</body>'); oDoc.close(); } catch(e) { self.print(); } } </script> </head> <body> <iframe id='ifrmPrint' src='' style="width:0px; height:0px;display:none;"></iframe> <div id="divToPrint"> Appropriately repurpose emerging applications with extensible testing procedures. Credibly envisioneer client-based experiences without open-source systems. Phosfluorescently evisculate economically sound manufactured products for standards compliant metrics. Compellingly develop corporate sources and team building architectures. Appropriately utilize professional products before emerging leadership skills. Appropriately synthesize premier human capital without robust outsourcing. Dynamically matrix cost effective materials after progressive niche markets. Credibly re-engineer real-time networks through resource-leveling value. Progressively integrate covalent infrastructures with one-to-one e-services. Distinctively embrace intermandated data rather than next-generation paradigms. </div> <br/><br/> <a href="javascript:" onclick="ClickHereToPrint()">Click here to Print above div</a> </body> </html> |