"Bonnett" wrote[color=blue]
> I have a piece of hidden text that the user can show/hide by clicking
> on a link, the problem I have is that I would like the text to appear
> when the page is printed.
> I've used the @media print in my CSS, and this shows the text when the
> page is printed without clicking on the link. However, if you show then
> hide the text (by clicking the link twice) the text does not appear in
> the print preview. It's as if the javascript is overriding the @media
> rule. Is there any other way to achieve what I am trying to do, or is
> it going to be impossible to display the hidden text when printed.
>
> I've prepared a test page here:
>
http://www.pete-b.co.uk/printProblem.htm
>
> I've have tested this on Firefox 1.0 and IE6, and any solution will
> only have to work on these browsers as the page is for a company
> intranet.[/color]
The initial hide is done with a class, then the javascript modifies the
style.display directly. Of course that overrides the properties set by the
class: it is more specific and will win the CSS cascade.
If you have the javascript toggle a className (by the way, elements can have
more than one classes, eparate them with commas) instead of the style
itself, then all should be well.
This function should give some clues:
function toggleclass(el,name){
if(el.className===''||el.className.indexOf(name)<0 ) {
el.className+=' '+name;
} else {
el.className=el.className.replace(name,'');
}
}
--
Ivo