Printing from a popup window

Recently one of my buddy tried to use window.print from a popup window
he were working on in webpage. And everytime he called window.print, it
doesn’t worked and the pop window went blank. He asked me to sort this out.

I tried out with this below technique and it worked.
Actually, window.print doesn’t work in a child window which is opened using the window.open method
we have to use it as

function printChildWindow() {
var newWindow = window.open("yourhtmlhere.html", "newWindow", "height=200,width=300");
......................
newWindow.document.close();
}
The window.print command stalls because the new window is still open
for input. If it is closed with windowName. document. close ; then the print
command will work as expected.

7 Replies to “Printing from a popup window”

  1. i tried the same thing myself, but i have bigger problem. the data in the print pop up is a report which is very huge width wise, it does show up in the pop up but does not print in the portrait. the report that is printed is cut and i could not see the data width wise.
    can anyone help me as ia m badly stuck up here and looking for any help thru diff web site.
    please help…..
    sabita

Leave a Reply to Md. Nazmul Hoque Cancel reply

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