I can edit the content before printing?

青春壹個敷衍的年華 提交于 2019-12-24 19:12:24

问题


The first chrome plugin to work. I do not have detailed information.

Before I print the contents of This link I want to get the specific part.

<table class="receiptSectionTable2Col" >

just how can I print the contents of this table. Is this possible?


回答1:


I think this answer from this question will help you:

HTMLElement.prototype.printMe = printMe;
function printMe(query){
  var myframe = document.createElement('IFRAME');
  myframe.domain = document.domain;
  myframe.style.position = "absolute";
  myframe.style.top = "-10000px";
  document.body.appendChild(myframe);
  myframe.contentDocument.write(this.innerHTML) ;
  setTimeout(function(){
  myframe.focus();
  myframe.contentWindow.print();
  myframe.parentNode.removeChild(myframe) ;// remove frame
  },3000); // wait for images to load inside iframe
  window.focus();
 }

Usage in your case:

document.getElementsByClassName("receiptSectionTable2Col")[0].printMe();


来源:https://stackoverflow.com/questions/47726892/i-can-edit-the-content-before-printing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!