PDA

View Full Version : Printing using an image


vinbeak
09-07-2006, 09:04 AM
Hi

I am looking for a way to call JavaScript commands by using an <a> tag on an image. For example say I have this code:

<a href="#"><img src="img/print_button.png" alt="Print Button" />&nbsp;Print</a>

How do I make it call something like

onclick="showPrintDialog();"

I maybe can't do this with an <a> tag so any help would be appreciated.

Thanks

RysChwith
09-07-2006, 01:12 PM
<a href = "#" onclick = "showPrintDialog(); return false"><img ... /></a>Or:<a href = "javascript:showPrintDialog()"><img ... /></a>Although, if you're relying on JavaScript, why not just do this?<img ... onclick = "showPrintDialog" />Note that there are no parentheses on the last one.

Rys

vinbeak
09-08-2006, 09:21 AM
Excellent, thanks for you help I will try them out. The reason I wanted to enclose them is the <a> tag is because the image will be a link but so will some text and I thought this would be the easiest way to deal with it.

RysChwith
09-08-2006, 01:20 PM
Ah. If there's text accompanying it, definitely use the <a> tag.

Rys