Page 1 of 1

window.print() vs ctrl+p

Posted: Wed Nov 04, 2015 2:50 pm
by rict
I have a button on the screen that is running in an iFrame. When I click the button, the on-click code executes window.print() and the print preview screen appears with just the contents of the iframe. When I press ctrl+p, the print preview appears but it shows the entire screen (the iframe and everything around it).

How can I make my print button work like the ctrl+p?

Thanks,
Ric

Re: window.print() vs ctrl+p

Posted: Wed Nov 04, 2015 5:15 pm
by Scott Klement
I have never done this, myself... but with a quick Google search I found a suggestion that if you first give focus to the parent of the iframe, you can print the whole page. To try this, set your onclick code like this:

Code: Select all

parent.window.focus(); window.print();
Does that help?

Re: window.print() vs ctrl+p

Posted: Wed Nov 04, 2015 6:43 pm
by rict
It was worth a try man, but it did not work. Thanks for your help.