I can edit the content before printing?

2019-08-19 09:51发布

问题:

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();