Posted: July 1st, 2010    By: Devin Walker   

Using JavaScript you can have images print when clicked on. What this script will do for you is open whatever image is specified in the JavaScript in a new browser window along with the Print options window.

This method is useful if you are looking for a way to have either a print button for a specific image on a page. Please refer to the demo to see exactly how this can be accomplished. Remember to specify the image's width and height in the JavaScript onClick event.



<img src="http://www.dlocc.com/articles/wp-content/uploads/2010/07/fluffy-kitten.jpg" alt="Print this Fluffy Kitten by Clicking Below" />
<a href="#" onclick='javascript:window.open("http://www.dlocc.com/articles/wp-content/uploads/2010/07/fluffy-kitten.jpg","mywindow","width=322,height=323,left=650,top=-1"); location.href="javascript:window.print()"'>Click to Print the Image Above</a>  

If you want to see the demo please click through and we'll show you how to use JavaScript to print images by clicking a link.

Demo JavaScript Print Image Button:

Print this Fluffy Kitten by Clicking Below Click to Print the Image Above

Related posts:

  1. Make Rounded Image, Photo and Graphic Corners in Photoshop The Internet fell into an obsession with rounded corners for awhile and you want to know to how create them? Ok, so first you'll need a graphic, image or photo that needs some rounded corners. Next follow along with this tutorial on how to create rounded corners for images, graphics and photos and you'll be [...]...
  2. JavaScript Email Address Validation JavaScript makes it easy to validate form fields such as the commonly used email address field.  For web designers trying to validate the email field, this simple script provided by Smart Webby works great.  I thought I'd pass this along, it can be used to easily validate the email field of your contact, comment, etc. [...]...
  • Richard

    This didn’t work for me. It printed out the entire page.

  • http://guii.com.uy Nacho

    This code not work, print all page

  • M Burke

    Doesn’t work, prints out ~this page~ not just the kitten.

  • jap

    As M Burke say your code doesnt work. Check before posting that what you publish is correct.

  • http:/www.dlocc.com Devin Walker

    How about you stop trolling?

  • Kaspalog

    instead of badmouthing your visitor, why don’t you fix your goddamn code and make sure your future posts are correct.

  • http://www.wordimpressed.com Devin Walker

    Why don’t you stop trolling and write your own ‘god damn’ code then? Comment deleted, you’re banned.

  • ir3t

    I have to agree with the others- your code prints out the whole page