Is there anyway using HTML or some simple JavaScript to put a button or link (button is better) that will automatically print the current page? Or at least open the PRINT window in the visitor's browser?
Thanks.
| SitePoint Sponsor |





Is there anyway using HTML or some simple JavaScript to put a button or link (button is better) that will automatically print the current page? Or at least open the PRINT window in the visitor's browser?
Thanks.
Ocean View Host - Affordable web hosting plans for any business.
Modern Technology, Old Fashioned Value & Service!
U.S. Merchant Services - Reliable merchant account services for all business!
Quality People Providing A Quality Service!





Go Here: http://dynamicdrive.com/
"Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
-- Albert Einstein





Or use this clever little snippet of code:
That renders a button, if you'd like to have a text link, or image link print the page, enclose it in a hyperlink like this:Code:<input type="button" value="Print" name="Button" onClick="window.print();return false">
AdyCode:<a href="#" onClick="window.print();return false">text or image</a>
v-technologies - Freelance Goodness.





Thanks!!
Ocean View Host - Affordable web hosting plans for any business.
Modern Technology, Old Fashioned Value & Service!
U.S. Merchant Services - Reliable merchant account services for all business!
Quality People Providing A Quality Service!


Hi Flufffykins, I'm also looking to set this function up, does your solution work across browsers and on Macs? Also what does the # stand for (in the href="#")?
Thanks for any help
gorillaweb is a small London based digital design agency.





Hi macdan.
The script I've used does work in IE 4+ and Netscape 4+ on a PC, but I've never tried it on a Mac so couldn't tell you about that one.
The # in the hyperlink simply makes an empty hyperlink. We can't have a hyperlink that doesn't point somewhere, but seeing as the link only serves to call some JavaScript to print the page out there's no point pointing it to another website or HTML page. Of course if we don't use an a href="#" we can't click on the text, so we need it to make a dummy link.
Hope that makes some sort of sense!
Ady
v-technologies - Freelance Goodness.


Thanks Ady, I'll give it a whirl and see what happens!
gorillaweb is a small London based digital design agency.
Bookmarks