2012年10月20日土曜日

ページ 印刷 (by A タグ、画像)

Using images as print buttons

Just like you can use custom images in place of submit/reset buttons, the same can be done with print buttons. There are two ways to go about creating image print buttons:

1st method: Using "return false" in an image link:

<a href="whatever.htm" onClick="window.print();return false"><img src="print.gif"></a>

Return false cancels the default action, which is to link to "whatever.htm". By cancelling the default action, the image above becomes exclusively a button that prints a document, which is what we want in this case. (Note: there is another similar way to achieve the same thing, which is to create a false (non existence) anchor link, and taking out the return false part.)


reference: from here

0 件のコメント: