How to print the contents of a hidden iframe?

I want to print the page that I put in the iframe, but I donโ€™t want the content to appear on the web page, but the print button does not work when I put the iframe to display = 'none'

what i did: - I set iframe style = 'none'

"name =" frame1 ">
<input type="button" onclick="frames['frame1'].print()" value="print!"> 

how can I print the contents of the iframe without displaying it on the web page or say keeping the ifram hidden

really appreciate any help .....

+2
html css ajax php iframe
source share
2 answers

You create a css file for printing, and in this file you have no display: none style.

 <link rel="stylesheet" type="text/css" href="/css/print.css" media="print" /> 

Here's a link to media types , thanks to Dror.

+7
source share

Instead of showing: no, you can try visibility: hidden and set the width and height to 1px each.

+1
source share

All Articles