469,303 Members | 2,007 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,303 developers. It's quick & easy.

Giving choices to users in print CSS?

How hard (and desireable) would it be to give the user certain choices when
it comes to printing web pages?

The pages on my site use colours and pictures and contain an imbedded menu,
among other things. Now, I could make certain assumptions on the user's
behalf, such as making the background white and the text black, suppressing
the menu from the printed page, and even suppressing the printing of the
pictures if they are merely decorative rather than functional. But that
might not please visitors who WANT some or all of those things.

Therefore, I'd like to know how hard it would be to give the user choices
when they click the Print (or Print Preview) buttons in their browser. For
instance, I could see a dialog like this appearing (I'll use "[]" to mean a
checkbox and "()" to mean a button):

----------------------------------------------------------------------------
-----------------------------------
1. [] print in same colours as the screen (if the box is unchecked, you will
get black text on white background)
2. [] print graphics that are strictly decorative (if the box is unchecked,
strictly decorative images will not be printed)
3. [] print the menu (if the box is unchecked, the menu will not be printed)

Check the appropriate boxes (if any), then click the Print button.

(Print) (Cancel)
----------------------------------------------------------------------------
-------------------------------------

The problem is that I'm not at all sure how I'd make that dialog appear or
how I would dynamically change the behaviour of the CSS based on the
selections the user made.

JavaScript might come in handy here but I know JavaScript is not considered
a good solution because of browser compatibility issues. I could make all of
my webpages Java applets but I know some people are notoriously reluctant to
install Java plugins in their browsers.

Is there a reasonable way to give the users choice or am I pretty much
forced to make the decisions for them? (Naturally, if I have to make the
decisions for them, I'm going to bend over backwards not to antagonize them
by printing black text on white and suppressing all but the most essential
information. Users who wanted their hard copies to match the screen will
just have to live with my choices.)

I'm basically a programmer and I try very hard to design programs so that
they give the user exactly what they want. Forcing everyone to live with my
choices of what will appear on the printed page and how it will appear
really goes against the grain....

--
Rhino
Nov 23 '05 #1
9 1518
Rhino wrote:
Therefore, I'd like to know how hard it would be to give the user choices
when they click the Print (or Print Preview) buttons in their browser.


I don't think you can do that.

Most browsers allow the user to set certain print options like whether
or not to print the page's background, so you could decide not to touch
the background in your print styles. But do you expect people to insist
on having a blue background printed? In that case, they can always make
a screenshot and print that :)

I guess you could also make an alternate (print) stylesheet which the
user could select, but browser support for that is scanty.

--
Garmt de Vries.

Nov 23 '05 #2
Rhino wrote:
Therefore, I'd like to know how hard it would be to give the user choices
when they click the Print (or Print Preview) buttons in their browser.


I don't think you can do that.

Most browsers allow the user to set certain print options like whether
or not to print the page's background, so you could decide not to touch
the background in your print styles. But do you expect people to insist
on having a blue background printed? In that case, they can always make
a screenshot and print that :)

I guess you could also make an alternate (print) stylesheet which the
user could select, but browser support for that is poor.

--
Garmt de Vries.

Nov 23 '05 #3

"Garmt de Vries" <gd*****@hotmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Rhino wrote:
Therefore, I'd like to know how hard it would be to give the user choices when they click the Print (or Print Preview) buttons in their browser.
I don't think you can do that.

Most browsers allow the user to set certain print options like whether
or not to print the page's background, so you could decide not to touch
the background in your print styles.


"No" is pretty much the answer I expected to get to my question ;-)

Still, it seemed worth asking in case a good technique for giving users
choices had emerged since I last dabbled with CSS.
But do you expect people to insist
on having a blue background printed?
I know that's not something that a huge percentage of people would want to
do but it seems like something that *some* people might want to do. I
certainly like the printed page to look just like the page they see on the
screen; only the relatively high cost of ink deters me from printing
coloured backgrounds and large colour pictures, especially those with dark
backgrounds.

But surely some people would have the attitude that they would prefer the
printed page to match what they see on the screen, even if it costs more.
That's why I'd like to be able to accomodate *both* kinds of users.
In that case, they can always make
a screenshot and print that :)
Granted. But many users are not sophisticated enough to know about
screenshot utilities; in fact, many probably wouldn't know where to find one
or how to install it even if someone told them they needed one. Also, some
people might not be authorized to install a program if it is a PC that they
are using at work.
I guess you could also make an alternate (print) stylesheet which the
user could select, but browser support for that is scanty.

Well, if the technique is only going to work on a few obscure browsers that
the vast majority of people are not going to have, then there's not much
point in doing it in the first place.

I'll just have to make the choices for the user and hope that, eventually,
CSS and browsers evolve to the point where some method of user selection of
print options is routine.

Thanks for confirming my suspicions that giving users control over printing
is not really practical, except at the general browser setting level.

Rhino
Nov 23 '05 #4

Rhino wrote:
I know that's not something that a huge percentage of people would want to
do but it seems like something that *some* people might want to do. I
certainly like the printed page to look just like the page they see on the
screen; only the relatively high cost of ink deters me from printing
coloured backgrounds and large colour pictures, especially those with dark
backgrounds.

But surely some people would have the attitude that they would prefer the
printed page to match what they see on the screen, even if it costs more.
That's why I'd like to be able to accomodate *both* kinds of users.


Don't forget that CSS is only a suggestion of how the page could look.
The user always has the option to ignore your print stylesheet if they
prefer to do so!

--
Garmt de Vries.

Nov 23 '05 #5

"Garmt de Vries" <gd*****@hotmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...

Rhino wrote:
I know that's not something that a huge percentage of people would want to do but it seems like something that *some* people might want to do. I
certainly like the printed page to look just like the page they see on the screen; only the relatively high cost of ink deters me from printing
coloured backgrounds and large colour pictures, especially those with dark backgrounds.

But surely some people would have the attitude that they would prefer the printed page to match what they see on the screen, even if it costs more. That's why I'd like to be able to accomodate *both* kinds of users.


Don't forget that CSS is only a suggestion of how the page could look.
The user always has the option to ignore your print stylesheet if they
prefer to do so!

Really? This is the first time I've heard that....

How would the user indicate that they want to ignore the CSS?

What rules would be applied to formatting the HTML page if the user elected
to ignore the CSS?

Rhino
Nov 23 '05 #6
Rhino wrote:
"Garmt de Vries" <gd*****@hotmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
Don't forget that CSS is only a suggestion of how the page could
look. The user always has the option to ignore your print stylesheet
if they prefer to do so!
Really? This is the first time I've heard that....

How would the user indicate that they want to ignore the CSS?


http://k75s.home.att.net/show/sfl-3.jpg :-0
What rules would be applied to formatting the HTML page if the user
elected to ignore the CSS?


HTML code only.

--
-bts
-Warning: I brake for lawn deer
Nov 23 '05 #7
Rhino,
I don't see why you can't implement your options using Javascript.

I was also a programmer in a past life (now retired) but I only have
about one year of using the web (on my home PC), i.e. HTML CSS and JS

But I am thinking:
Can't you get JS to write the CSS you want based on the user's choice?

My thoughts:

Insert a named <div> in your HTML:
<div id ="printcss"></div>

Then add a print button somewhere lower down
<button onclick="printfn() value="Print this document"></button>

In printfn(), you ask various questions (using prompt) and use the
returned answers to set up the "whatever" in the body style below

var whatever
document.getElementById('printcss').innerHTML=
'<style type = "text/css"> body{'
+ whatever
+ '}</style>'
print()

I haven't done any testing at all. These are just ideas off the top of
my head. I don't know whether writing a new style into the document
immediately before printing will work. But why wouldn't it ?

I'd be interested to know whether you try this idea and if so, have any
success

Nov 23 '05 #8

Trevor L. wrote:
Insert a named <div> in your HTML:
<div id ="printcss"></div>

Then add a print button somewhere lower down
<button onclick="printfn() value="Print this document"></button>

In printfn(), you ask various questions (using prompt) and use the
returned answers to set up the "whatever" in the body style below


This may work, but it won't be correct. The <style> is supposed to go
in the <head> section. Even if you use JS to put some new CSS in the
<head>, I, as a user, would be rather annoyed if you forced me to go
through a series of questions every time I wanted to print a page from
your site.

--
Garmt de Vries.

Nov 23 '05 #9
> "Garmt de Vries" <gd*****@hotmail.com> wrote in message
Don't forget that CSS is only a suggestion of how the page could look.
The user always has the option to ignore your print stylesheet if they
prefer to do so!

Rhino wrote: Really? This is the first time I've heard that....
Read about cascading in the CSS specs.
How would the user indicate that they want to ignore the CSS?
Depends on the user agent (brower).
What rules would be applied to formatting the HTML page if the user elected
to ignore the CSS?


user agent "CSS"

--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
Nov 23 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Mica Cooper | last post: by
6 posts views Thread by apngss | last post: by
198 posts views Thread by Sy Borg | last post: by
1 post views Thread by John Baker | last post: by
reply views Thread by cameron | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.