Reg Exp
Web Design
Notes Client
Printer Friendly Pages
Many applications have "printer friendly" version of different documents. It eliminates all the navigation and other items and just gives something that can be printed. This can be done with CSS, but you may not have chosen to implement another style sheet for printing. For example, many times its more comforting to the end user to know for sure that all the other stuff around won't print. Many users are familiar with a "printer friendly" link in applications and it may take time for them to become familiar enough to realize that CSS can do this for them. There may be other reasons.

So let's assume for the time being that you have a "printer friendly" link that takes the user to another page (maybe opens up a new browser window, but doesn't have to) that contains only the stuff the user wants to print. You can make that page even more beneficial to the user with just one line of JavaScript.

In the page's "onLoad" event, you should add a line of JavaScript that brings up the browser's print capability and the closes the window (if you opened another window) or goes back to the previous page (if you didn't open another window). In the example where a new window was opened, here's the JavaScript you can put into the onLoad event:

if (window.print) { window.print(); window.close(); }

When the page is done loading, the browser's print dialog box will open, allowing the user to print the document, and then after the print dialog is closed (because the user clicked OK or Cancel) the "printer friendly" window will be closed. This just makes things easier on your users - they click on the "printer friendly" link because they want to print, don't they?