views:

31

answers:

2

I understand I can call window.print() when the page loads to load the print dialog, but can I force the window to be minimised from the point that it's opened and the print dialog is generated? Ideally it would be minimised until the user maximises it. Thanks

A: 

you could try to open a new window outside the screen bounds so it's not visible. (x=-10000, y=-2000). Then, when it's loaded, print it and close it.

Run CMD
+1  A: 

Short answer: No.

Abbreviated answer: you'll have every antispam tool against you if you try to open windows and play with then in javascript.

But... you could use the help of @media print {} in css. Add a div with the content you want to print to the page (and load it via Ajax, or using an iframe). By using "@media print" rules in the CSS you can tell the browser to hide the page that the user is seeing in the browser (by including it in a big div and adding a display:none to the print rule) and show the hidden div. The nice thing of this solution is that you can play with both divs via javascript, for example you could add buttons to show/hide the print div, etc.

salgiza