I am looking for a way to add parameters on a print function, because I have to print only the table and when I alert the table it shows me the correct value but when I'm printing it prints the entire page.
My code is
aa = document.getElementById('tablename').innerHTML
If I alert(aa)
it gives me the write value
then I print(aa)
it give me the entire page.
so I tried print(aa)
and aa.print
and it doesn't work.
Does anyone know the solution for this?
Print stylesheets are nice, but you can still accomplish this in Javascript. Just pass your value to be printed to the following function...
function printIt(printThis) {
var win = window.open();
self.focus();
win.document.open();
win.document.write('<'+'html'+'><'+'body'+'>');
win.document.write(printThis);
win.document.write('<'+'/body'+'><'+'/html'+'>');
win.document.close();
win.print();
win.close();
}
Define a print stylesheet which will only display the table.
There's no need for it to be dynamic.
Simply define those sections you don't wan to see as display:none (as stated in the alistapart article)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With