Ivo wrote:[color=blue]
> "Mark Preston" wrote[color=green]
>> So - how do you think the user should go about printing the
>> whole page, with all <div> layers visible, even if normally
>> switched off, and at the same time ignoring the menu (much
>> as I've ignored it here)?
>>
>> At an initial look, there seem to be three approaches. First,
>> the CSS could be used to build a print media version - perhaps
>> switching stylesheets with JavaScript.[/color][/color]
Printer specific style sheets would be easiest to apply, as the browser
would be doing that for you in the appropriate context. Otherwise you
would have to be reacting to the not universally supported -
onbeforeprint - event or asking the user to switch style sheets prior to
printing (maybe not a bad idea as a "display this page in a format
suited to printing" option is not too different from offering another
version tailored to printing).
[color=blue][color=green]
>> Second, the script could be used to switch all
>> the 'off' layers back 'on' before printing.[/color][/color]
Again the - onbeforeprint - event would be needed to do the switching,
or the user would have to do it.
[color=blue][color=green]
>> Third, a separate page could be provided especially for the
>> purpose.[/color][/color]
I would not ever recommend alternative pages for printing, in the sense
that those pages are alternative human authored and fixed resources on
the server, because that is doubling creation/maintenance costs and
introducing a realistic possibility of the two getting out of sync. If
there is one server-side source for the content (database or whatever)
and the pages are dynamically assembled or pre-processed then a printer
tailored version could be just one additional sever-side script (or
pre-processing step).
[color=blue]
> You have a stylesheet for the screen, and another for the
> printer. I don't see the problem. There is no reliance on
> javascript.
>
> <style type="text/css" media="print">
> div { display:block; visibility:visible; }
> </style>
> <URL:
http://www.w3.org/TR/REC-CSS2/media.html >[/color]
Mixing the dynamic displaying and hiding of contents with scripts and a
desire to include all of the content when printing would not necessarily
be entirely solved with printer specific style sheets in that style.
Problems would arise due to the cascaded nature of CSS assignments
depending on how the display/hiding was achieved. When CSS is applied to
an HTML document any STYLE attributes local to the HTML elements will
override all CSS assignments originating in external style sheets and
STYLE elements in the HEAD (because they are defined as being as
specific as ID selectors, but also appear later and so override equally
specific rules that precede them). So a local STYLE attribute will
override a printer specific style sheet. Unfortunately there does not
appear to be a mechanism form making STYLE attributes media specific.
The - style - object associated with HTML elements within the DOM is the
representation of the STYLE attribute so any content manipulation
achieved by setting properties on the - style - object is equivalent to
re-defining a local STYLE attribute. Thus they will override assignments
from STYLE elements and external style sheets. The use of the - style -
object in switching visibility/display/z-indexes is normal/common, so
its place in the cascading rules of CSS is significant.
Alternative approaches might include; setting the - className -
properties of DOM elements instead of - style - object properties, then
CSS class definitions would be derived from the appropriate media
specific style sheet (generally regarded as a heavyweight alternative to
setting individual - style - object properties).
Otherwise the CSS - ! important - declaration could be used in print
specific style sheets to have the element specific style attributes
ignored (probably the best options if it can be demonstrated to work
sufficiently well).
Richard.