0

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?

alon3wolf
  • 33
  • 8

1 Answers1

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();
Luka Čelebić
  • 1,083
  • 11
  • 21
  • First of all thank you for your reply. I could not do for this example... https://developer.chrome.com/extensions/examples/api/bookmarks/basic.zip – alon3wolf Dec 09 '17 at 17:22
  • I have no idea what exactly do you require but I'm guessing you're probably going to need a [content script](https://developer.chrome.com/extensions/content_scripts) to achieve it. You should edit your question to be more specific about a problem that you are having if you want me to help you. – Luka Čelebić Dec 09 '17 at 18:26
  • I want to print the page that l specified in the above address in the 58mm chip printer. I want to print only the specified locations on that page (the div content l specified). I wanted to do this via the chrome extension print sample, but l could not. I want to print the specific area on the page http://sezgin.net.tr/fatura.html when l press the print icon. – alon3wolf Dec 10 '17 at 09:01
  • @alon3wolf If you go to the site and paste this function and call it in the chrome developer console (ctrl+shift+j) you will be prompted to print only that required part. To achieve that through a chrome extension you need to make a new one and put this code inside a content script. I recommend you research more about the extensions and their [architecture](https://developer.chrome.com/extensions/overview#arch). – Luka Čelebić Dec 10 '17 at 12:37