By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,724 Members | 1,707 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,724 IT Pros & Developers. It's quick & easy.

Content visible only to print stylesheets

P: n/a
Hi,

A website I work on has a print stylesheet to strip navigation and things out
of a page, and changes the fonts and various bits and pieces here and there.
What I'd also like is something small (a footer, perhaps) that says something
along the lines of 'you are viewing a printed version of [TITLE], available
at [url]'. I know I can do this by just adding the content and using display:
none for the screen CSS, but then it becomes visible in text browsers, which
I don't want. It would also have to work in IE, which means I couldn't use
the :before or :after pseudo-elements...

Is there any way to achieve this?

--
"If man were meant to fly in outer space, God would have given him a brain
capable of figuring out the mathematics and physics necessary to do so."
- The Onion
Jul 20 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
la_haine wrote:
A website I work on has a print stylesheet to strip navigation and things out
of a page, and changes the fonts and various bits and pieces here and there.
What I'd also like is something small (a footer, perhaps) that says something
along the lines of 'you are viewing a printed version of [TITLE], available
at [url]'. I know I can do this by just adding the content and using display:
none for the screen CSS, but then it becomes visible in text browsers, which
I don't want. It would also have to work in IE, which means I couldn't use
the :before or :after pseudo-elements...

Is there any way to achieve this?


The only way I can think of is to insert an empty element at the bottom
of each page, and set its background-image to an image of the text you
want in the print stylesheet. Sizing that element is left as an exercise...

--
Mark.
Jul 20 '05 #2

P: n/a
"la_haine" <p.*****@kent.ac.uk> wrote:
A website I work on has a print stylesheet to strip navigation and things out
of a page, and changes the fonts and various bits and pieces here and there.
What I'd also like is something small (a footer, perhaps) that says something
along the lines of 'you are viewing a printed version of [TITLE], available
at [url]'.
Many browsers display the page title and URL in the header and/or
footer of the printed page. So is this really necessary?
I know I can do this by just adding the content and using display:
none for the screen CSS, but then it becomes visible in text browsers, which
I don't want. It would also have to work in IE, which means I couldn't use
the :before or :after pseudo-elements...

Is there any way to achieve this?


Not reliably. You could make an image of the text and include it via
the print CSS as a background image, but many browsers are set not to
print background images.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 20 '05 #3

P: n/a

"la_haine" <p.*****@kent.ac.uk> wrote in message
news:c9**********@athena.ukc.ac.uk...
Hi,

A website I work on has a print stylesheet to strip navigation and things out of a page, and changes the fonts and various bits and pieces here and there. What I'd also like is something small (a footer, perhaps) that says something along the lines of 'you are viewing a printed version of [TITLE], available at [url]'.


All the browsers I have on my computer (Netscape 4.7 and 7, IE 6, Opera
7.21, Mozilla 1.5, Firefox 0.8) show this information anyway, except for the
part about the printout being a printed version, which is self-evident. So
what's the point?

Jul 20 '05 #4

P: n/a
"Harlan Messinger" <h.*********@comcast.net> wrote in
news:2i************@uni-berlin.de:
All the browsers I have on my computer (Netscape 4.7 and 7, IE 6, Opera
7.21, Mozilla 1.5, Firefox 0.8) show this information anyway, except for
the part about the printout being a printed version, which is
self-evident. So what's the point?


None really. And apparently it can't be done anyway. So never mind!

--
Time flies like an arrow; fruit flies like a banana.
Jul 20 '05 #5

P: n/a
"la_haine" <p.*****@kent.ac.uk> wrote in message news:<c9**********@athena.ukc.ac.uk>...
"Harlan Messinger" <h.*********@comcast.net> wrote in
news:2i************@uni-berlin.de:
All the browsers I have on my computer (Netscape 4.7 and 7, IE 6, Opera
7.21, Mozilla 1.5, Firefox 0.8) show this information anyway, except for
the part about the printout being a printed version, which is
self-evident. So what's the point?


None really. And apparently it can't be done anyway. So never mind!


Just because you said it can't be done and for laughs, what does your
text browser do with the following?:

<script>
document.write("<div id='printNote'><p> Style for print only and it
fits the bill for your 'JS' enabled viewers.</p></div>");
</script>

Or you could go with some server side browser detection and improve on
the percentage.

So there are a few options actually on how to do it. Maybe a
document.write <img src blah blah...> would be better.

No comment on the over kill of all this to label a printed document as
such will be included. Just need to bang my head against the wall when
someone says it can't be done. Why? Because it feels so good when you
stop obviously.

Cheers!
Jul 20 '05 #6

P: n/a
On 4 Jun 2004 20:57:44 -0700, bg***@yahoo.com (Nairb) wrote:

Just because you said it can't be done and for laughs, what does your
text browser do with the following?:

<script>
document.write("<div id='printNote'><p> Style for print only and it
fits the bill for your 'JS' enabled viewers.</p></div>");
</script>


While currently no popular text-only browser supports scripting, it's
probably best not to assume one never will. One day a text browser
might be released which supports CSS, too!

-Claire
Jul 20 '05 #7

P: n/a
Claire Tucker <fa**@invalid.com> wrote in message news:<6t********************************@4ax.com>. ..
On 4 Jun 2004 20:57:44 -0700, bg***@yahoo.com (Nairb) wrote:

Just because you said it can't be done and for laughs, what does your
text browser do with the following?:

<script>
document.write("<div id='printNote'><p> Style for print only and it
fits the bill for your 'JS' enabled viewers.</p></div>");
</script>


While currently no popular text-only browser supports scripting, it's
probably best not to assume one never will. One day a text browser
might be released which supports CSS, too!

-Claire


I had not considered 100% future compatibility. Your right. I think we
better form a committee and delve into this further. As logic goes,
eventually web browsers be they text based or not, at some point in
the future will no longer even support HTML as we know it. Therefore
you may as well pull all your sites down now and face the inevitable.
Jul 20 '05 #8

P: n/a
Claire Tucker <fa**@invalid.com> writes:
On 4 Jun 2004 20:57:44 -0700, bg***@yahoo.com (Nairb) wrote:
Just because you said it can't be done and for laughs, what does your
text browser do with the following?:

<script>
document.write("<div id='printNote'><p> Style for print only and it
fits the bill for your 'JS' enabled viewers.</p></div>");
</script>

Two (lynx, w3m) ignore it, the other (links 2) displays the HTML content.
While currently no popular text-only browser supports scripting, it's
probably best not to assume one never will. One day a text browser
might be released which supports CSS, too!


Hmm, Links2 (text-only) supports Javascript. I don't think it's
particularly less popular than lynx or w3m, I think it's the default
on some Linuxes.

And doesn't emacs-w3 have some stylesheet support?

--
Chris
Jul 20 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.