Skip to content Skip to sidebar Skip to footer

Print A Specific Div Using Javascript

I m using a javascript code that print a specific div.. This code is working fine but it shows a header url and footer automatically when i print it... I can handle it from chrome

Solution 1:

You cannot control printing of headers and footers inside your page as they are controlled by browser preferences.

You can change the preferences on your machine (firefox and IE) via the guide here

Note: This only changes your local settings and won't affect users printing your page on their machines.

Solution 2:

<scripttype="text/javascript">functionprintDiv() {    
var printContents = document.getElementById('Your printable div').innerHTML;
var originalContents = document.body.innerHTML;
 document.body.innerHTML = printContents;
 window.print();
 document.body.innerHTML = originalContents;
}

Post a Comment for "Print A Specific Div Using Javascript"