printing webpage without opening new window using jQuery

Print is a create a big problem to mostly developers (I’m one of them). The problem like “print without opening new window”.
Today, in this post I write a solutions of same problem.

The solutions is :

Use Jquery/Javascript with iframe elements. Small code for solution is below.

var theUrl="print.html"; 
$("<iframe>")                            // create a new iframe element
        .hide()                               // make it invisible
        .attr("src", theUrl) // point the iframe to the page you want to print
        .appendTo("body"); 
and Use window.print() method in the print file which you want to print.

If you have any confusion then comment it.


Comments

Leave a Reply

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