I am trying to setup a link that will allow a user to print the current page using JavaScript. It should open the print dialog box and then from there the user is able to print using their desired printer.
Hi Omar,
There are a few ways to go about setting up a JavaScript print option all of which use the window.print() function. The print function opens the print dialog box as you mentioned and gives the user the choice of printer and options.
JavaScript Print via text link
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
<a href="javascript:window.print()">Print Me!</a>
JavaScript Print via image link
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
<a href="javascript:window.print()"><img src="/images/print_button.gif" /></a>
Automatically calling the print function
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
In the body of your page you can add the print function to your onLoad event. This is typically used when a user options a printer friendly version of your page as their action would hint their intention to print.