views:

725

answers:

2

i want to print a page which i put in an iframe but dont want the contents to be displayed in the webpage , but the print button doesnt work when i put the iframe to display='none'

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

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

how can i print the contents of iframe without displaying it on the webpage or say by keeping the ifram hidden

would really appreciate any help.....

+6  A: 

You do a print css file, and within that file you do not have the 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.

Ólafur Waage
Oh, I like your answer better than mine..
Stephen
Then give me a +1 :P
Ólafur Waage
I gave +1! also here is a link to media types: http://www.w3.org/TR/CSS2/media.html
Dror
A: 

Instead of display: none, you could try visibility: hidden and setting the width and height to 1px each.

Stephen
Erm, negative vote? At least this solution works.
Stephen