Web Hosting Talk







View Full Version : Print Page code


iFuseDavid
07-05-2006, 03:56 PM
Im trying to set up a way where a user can print a document without all the navbar, menu, and all that junk. I just want the text to be printed. So I thought I could just create a printer friendly html page with just the document. However on the main html page I want a link to automatically print the printly friently html page.

something like window.print() but is there I way to do something like 'printly-friendly.html'.print().

I thought about just making a link to printly-friendly.html and then on load do window.print and then history(-1) but I think the first way would be more prefessional

Fixago
07-05-2006, 11:52 PM
You could make a CSS stylesheet with a media type "print," that way only what you want would show up.

stripeyteapot
07-06-2006, 12:58 AM
Ditto Fixago.

@media print {
#navbar {display:none;}
}

tobiasly
07-06-2006, 01:16 AM
I'll "third" Faxago's answer. Trying to create and maintain "printer friendly" links is a nightmare.

To see how well using separate styles in screen vs. print media works, check out Google Maps. For example, open up this URL in your browser: http://maps.google.com/?ie=UTF8&lr=lang_en&hl=en&q=jfk+to+350+5th+ave,+new+york&f=q&om=1

Notice there is no "Printer Friendly" link, just a "Print" link that just calls window.print(). Now open up the page in your browser's Print Preview. See how the search box is gone, and the directions are printed below the map instead of to the left? It's all done through media-specific CSS, as Pauly's example above shows.