Code snippet to format and Print Html from Javascript


$('#print').click(
function() {
var data = $('#header').html() +""+$('#terms').html()+"";
var mywindow = window.open('', 'my div', 'height=400,width=600');
mywindow.document.write('');
mywindow.document.write(data);
mywindow.document.write('');

mywindow.document.close(); // necessary for IE >= 10
mywindow.focus(); // necessary for IE >= 10

mywindow.print();
mywindow.close();

return true;
});

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>