chrome window.print() window.close()

Chrome used to open a seperate window containing just the element i wanted printed and its relative css. That window then spawned the .print command which opened another window containing print preview.

Now Chrome no longer opens a new window for their print preview. Instead it opens a “dialog with overlay” in the current page to be printed.

So if you use

<script type="text/javascript">

to print the current page, the window will close and nothing will be printed.

For some reason Chrome don’t start the timeout timer until the print dialog is closed.
what we can do is:

<script type="text/javascript">
   setTimeout('window.close()', 10);

basically seTimeout is called only when the document is focused which happens only when the overlay print dialog is closed.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s