Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
145
rated 0 times [  147] [ 2]  / answers: 1 / hits: 51259  / 12 Years ago, tue, april 10, 2012, 12:00:00

I have a html page, from which a table needs to be sent to a printer. I am using window.print right now.. but that prints the whole page... while I need to print just the table. Any ideas?


More From » html

 Answers
8

  1. You can use media types print (here is tips, how print html page using stylesheets).


  2. You can realize that through popup window - in this window show only table and send it to printer.




Simple example



<script>
function printDiv() {
var divToPrint = document.getElementById('areaToPrint');
newWin = window.open();
newWin.document.write(divToPrint.outerHTML);
newWin.print();
newWin.close();
}
</script>

[#86335] Monday, April 9, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
terrances

Total Points: 184
Total Questions: 100
Total Answers: 92

Location: Tokelau
Member since Sun, May 7, 2023
1 Year ago
;