I am trying to add a footer at the end of my html page. I want it to be hidden when the page is displayed, but want it show up when the page is printed. I tried something like the following, which I don't think is right. out.write("<div style=\"visibility:hidden\">"); out.write("The hidden text"); out.write("</div>"); Code (markup): out.write("<div style=\"display:none\">"); out.write("The hidden text"); out.write("</div>"); Code (markup): Any suggestions? Thanks.
Don't use Javascript to do this. Use CSS. You can actually specify to use a different CSS style sheet when printing. You can read more about it here: http://www.w3.org/TR/REC-CSS2/media.html You basically put something like this is your <head> tag. <LINK rel="stylesheet" type="text/css" media="print" href="print.css"> Code (markup): Then you specify how you want the document to look when printed in the "print.css" file by using CSS.
...OR... If your footer has a background colour, it gets better: make your text the same colour as the footer background colour. It's now invisible (watch out, google may delist a site with invisible text...). Printers usually default to NOT printing the background colours when printing in B&W (colour printing, though, would need the seperate CSS import like Foo said).
use css by using background color same to the text... but using invisible text is not good with google