Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. <script>
  2. ...
  3. jQuery(document).ready(function($) {
  4. $('#printerButton').click(function(){
  5. openPrintDialogue();
  6. });
  7. });
  8. function openPrintDialogue(){
  9. $('<iframe>', {
  10. id: 'frame',
  11. scr: 'path/to/my/external/html/file',
  12. name: 'myiframe',
  13. class: 'printFrame'
  14. })
  15. .appendTo('body');
  16.  
  17. window.frames['myiframe'].focus();
  18. window.frames['myiframe'].print();
  19.  
  20. setTimeout(() => { $(".printFrame").remove(); }, 1000);
  21. };
  22. ...
  23. </script>
  24. <html>
  25. ...
  26. <input type="button" id="printerButton" name="print" value="Print It" />
  27. ...
  28. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement