PDA

View Full Version : Apply JS to a picture


no way
01-06-2003, 08:41 PM
Hi again.

Is it possible to apply the following script to an image (say print.gif) ?


<script>function printWindow() {
bV = parseInt(navigator.appVersion);
if (bV >= 4) window.print();
}</SCRIPT>

Thks
Fred :thumbsup:

scroots
01-06-2003, 08:53 PM
you know how to hyperlink images you do that but for the target you put javascript:printWindow() or you can set a target to # and add onClick="printWindow()"

scroots

no way
01-06-2003, 09:11 PM
thks Scroots, but that's too high for me :o

I'm there:

<a href target="javascript printWindow()">
<img src="Pic_print.gif"></a>

... and now ?

Fred.

cg9com
01-06-2003, 09:20 PM
quick elaboration on scroots way

<a href="javascript:printwindow()"><img src="print.gif" alt="" /></a>

if you need the href use onclick

<a href="" onclick="printwindow()"><img src="print.gif" alt="" /></a>

no way
01-06-2003, 10:22 PM
I'm sorry, but it's still not working.

mmmmh !?! :confused:

http://www.geocities.com/verybadpage/page3.html

Fred.

cg9com
01-07-2003, 05:56 AM
i didnt see a printwindow function in your source ( maybe i missed it )
but you can also use just <a href="javascript:print()"></a>
doesnt require anything else