0

I've read several posts about this, but I write what happens to me. I have this code:

$(document).ready(function() {
    window.print();
    window.close();
});

Ok. Print dialog appears. When I click 'print', my window is closed, but it doesn't print anything. I think that window is closed very quickly.

I can set a setTimeout, but I don't know if I going to print one page or one hundred pages. This solution doesn't valid to me.

With javascript or jquery can I control the print job? Objetive is close the window when the pages have been printed.

monicapo
  • 111
  • 1
  • 12
  • I think this is a solution for your problem http://stackoverflow.com/questions/18325025/how-to-detect-window-print-finish – Stepashka May 19 '15 at 08:08
  • How about this: instead of a pop-up window, use an iframe, where you have ``. All you have to do is give the iframe a name, set a few links with `target="iframe_name"` and you are set! You can hide the iframe with `style="display:none"`. – Ismael Miguel May 19 '15 at 08:26

1 Answers1

0

may this will help you,

$(document).ready(function() {
    window.print();
    window.onfocus=function(){ window.close();}
});
iTechOwl
  • 150
  • 11