abc

Share This blog with your friends, so that we can improve more & more . our aim is to easy & simple way of learning.

4/07/2019

Print with preview window using javascript

print preview area using simple jquery.
no need any extra api or script .
just use below code to print form or DIV part 
 
$('#printA').click(function(){  
 
    var content = document.getElementById('printcontent').innerHTML; 
  var mywindow = window.open('', 'Print', 'height=600,width=800');
    mywindow.document.write('<html><head><title>Print Content</title>');
    mywindow.document.write('</head><body >');
    mywindow.document.write(content);
    mywindow.document.write('</body></html>');
    mywindow.document.close();
    mywindow.focus();
    mywindow.print();
    mywindow.close();
    
    return true;
 
});
 
to use above code do simple steps.
1. ensure jquery.min.js is use or simple use above to javascript
2. print button
3. onclick of this button above code will paste
4. simplly open print window 
5. suppose after filling form or displaying data print function is needed then use above print function
 

1 comment:

An Introduction to the Laravel Framework: What It Is and Why You Should Use It

  If you're a PHP developer looking for a modern, efficient, and powerful framework to build web applications, look no further than Lara...