Papermashup

Subscribe


Tweets


"RT @bethgordon: .@Tesco Please rethink archaic 'Approved by Mums'. Pretty sure it's not just mothers who make childcare decisions. https://…"

@ashleyford 4 days ago

"Is there ever a time that @DFS doesn't have a sale on?"

@ashleyford 1 week ago

Designer and web developer, Co-founder and Technical Director at Harkable.com. Previously I worked at Spotify, MySpace and InMobi. Contact me - ashley[at]papermashup.com

Creating a JavaScript print link

AshleyAshley

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>

Designer and web developer, Co-founder and Technical Director at Harkable.com. Previously I worked at Spotify, MySpace and InMobi. Contact me - ashley[at]papermashup.com

Comments 1
  • visualsuspect
    Posted on

    visualsuspect visualsuspect

    Reply Author

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