Creating a JavaScript print link
How many times have you booked that holiday or purchased a new gadget and been presented with a button that says ‘Print your receipt’? Users generally have to be pushed into executing a physical action such as printing a receipt or confirmation letter. So to do this we can use a simple line of JavaScript that goes in the href of our link to open the print page prompt window.
It’s also worth pointing out that to get the best results, its best to create a print style sheet that will format your page in a user-friendly format. Print style sheets have been around for some time yet very few sites have implemented them.
<link rel="stylesheet" href="print.css" type="text/css" media="print" />
Here is the code to add a print button to your site.
<a href="javascript:window.print();">Print Page</a>








Probably going to need this in an upcoming project, so right on time! I don’t have to google for it anymore.
Leave a comment...