Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. function printElementSimple(elem){
  2. w=window.open();
  3. w.document.write($(elem).html());
  4. w.print();
  5. w.close();
  6. }
  7.  
  8. document.getElementById('preview-viewer').contentWindow.print()
  9.  
  10. function printElement(elem, style){
  11.  
  12. if (document.getElementById != null){
  13. var html = '<HTML>\n<HEAD>\n';
  14. if (document.getElementsByTagName != null){
  15. var headTags = document.getElementsByTagName("head");
  16. if (headTags.length > 0) {
  17. html += headTags[0].innerHTML;
  18. }
  19. }
  20.  
  21. html += "<STYLE>"+style+"</STYLE>";
  22.  
  23. html += '\n</HEAD>\n<BODY>\n';
  24. var elem = elem
  25.  
  26. if (elem != null) html += elem.innerHTML;
  27. else{
  28. alert("Error, no contents.");
  29. return;
  30. }
  31.  
  32. html += '\n</BODY>\n</HTML>';
  33. var printWin = window.open("","PrintWindow");
  34. printWin.document.open();
  35. printWin.document.write(html);
  36. printWin.document.close();
  37.  
  38. //printWin.print();
  39.  
  40. } else alert("Browser not supported.");
  41.  
  42. }
  43. var style = "td span, td del, td ins { word-break: break-word;} del { color: #000; background: #f88; text-decoration: none;} ins {color: #000; background: #9f9; text-decoration: none;}"
  44. printElement($('.pad-top-md>.ng-star-inserted'),style);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement