I have the following html code:
don\'t print th
http://...domain.../path.css
or so. It creates separate HTML document and it has no context of main thing.This served me for years now:
export default function printDiv({divId, title}) {
let mywindow = window.open('', 'PRINT', 'height=650,width=900,top=100,left=150');
mywindow.document.write(`${title} `);
mywindow.document.write('');
mywindow.document.write(document.getElementById(divId).innerHTML);
mywindow.document.write('');
mywindow.document.close(); // necessary for IE >= 10
mywindow.focus(); // necessary for IE >= 10*/
mywindow.print();
mywindow.close();
return true;
}