...

View Full Version : footer that prints but doesn't render?



patrik
10-31-2002, 10:19 PM
Is there an easy way to insert a line of type (say contact information) that would print but doesn't render or show onscreen?

I've tried making the text the background color, but of course a light background means while you don't see it onscreen, you also don't see much of it when printed as it's light grey (on a b/w printer) rather than black.

TIA!

Roy Sinclair
10-31-2002, 10:35 PM
In the <head>:



<style type="text/css">
.printOnly { visibility: hidden; }
@media print { .printOnly { visibility: visible; }}
</style>


In the <body>:



<div class="printOnly">
This won't show on the screen but will print.
</div>

patrik
10-31-2002, 10:59 PM
Wow - that was fast!
Is it safe to assume this won't conflict with my present external CSS file?

Many thanks!

Roy Sinclair
11-01-2002, 03:26 PM
It'll only conflict if the class name conflicts. Of course you could always add the new class to the external file instead of the single document.

patrik
11-01-2002, 07:38 PM
Hmm.. very strange results once implemented - Rats!

In IE 5.0, type is correctly invisible, but fails to print.

In Netscape 4.x, type prints, but unfortunately also remains visible on screen.

For the sake of troubleshooting, here's my code copied from files in question, and pasted here.
From the header:
----------------------------
<style type="text/css">
.printOnly { visibility: hidden; }
@media print { .printOnly { visibility: visible; }}
</style>
----------------------------

From the <body>:
----------------------------
<div class="printOnly">Mytext</div>
----------------------------

Can you elaborate on the "@media" bit?

Thanks again!

Roy Sinclair
11-01-2002, 10:18 PM
If this needs to support Netscape 4 then you might as well forget it entirely. It's simply not possible in Netscape 4. With Netscape 6 (or other Gecko based browsers) it should work fine and I've done the opposite of what you asked in IE 5 as well so I'm not sure why it's not working. I can't test it in IE 5 now since I have IE 6 instead (grumble, grumble MS and their too tight integration with the OS). FWIW, it worked fine in IE 6 when I put it into a sample page.

For the official notes on @media: http://www.w3.org/TR/CSS2/media.html



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum