Papermashup

Subscribe


Tweets


"RT @danbarker: Strangely I saw a really shifty guy drop his wallet earlier today in London. When I handed it back he said "Let me give you…"

@ashleyford 7 hours ago

"RT @McDonaldsCorp: Black Friday **** Need copy and link****"

@ashleyford 7 hours 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.