29

Can I put a link on my webpage to the Printer ?

To go to the same page like Ctrl-P goes in Firefox, IE.

Thank you.

Cristi
  • 429
  • 1
  • 4
  • 8

2 Answers2

55
<a href="javascript:if(window.print)window.print()">Print</a>
dave4420
  • 46,404
  • 6
  • 118
  • 152
  • Is there a similar way to print another URL in this fashion? (As opposed to the current one.) For example a list where each line represents a file and each line contains a print button/link. (So you could print the destination file before actually visiting the link and going to that page.) – Jay Jul 18 '17 at 18:04
  • The simplest way I can think of involves opening the page you want to print in a new window, and that page doing `window.print(); window.close()`. But perhaps there's a simpler way I don't know about. Try asking as a new top level question. – dave4420 Jul 18 '17 at 20:45
10

Add this to your link:

onclick="window.print();"
cjk
  • 45,739
  • 9
  • 81
  • 112