I am going to print the html table using the button and onclick function. when I try to do this, they always prompt me with a window, and from there I press the print button again. then only the printer will go to the printer.
so I want to print this table with one button and without a hint for a preview, is it possible to do this? And How?
I use this code to print a table.
function printlayout() {
var data = '<input type="button" value="Print this page" onClick="window.print()">';
var DocumentContainer = document.getElementById('printlayout');
var WindowObject = window.open('', "TrackHistoryData",
"width=740,height=325,top=200,left=250,toolbars=no,scrollbars=yes,status=no,resizable=no");
WindowObject.document.writeln(DocumentContainer.innerHTML);
WindowObject.document.close();
WindowObject.focus();
WindowObject.print();
WindowObject.close();
}
I know that there are thousands of questions, but nothing helped me solve my problem. I mainly focus the Chrome Chrome browser to launch my application.
source
share