Thursday, 5 June 2014

For Beginners : Printing webpages using java script:

For Beginners : Printing webpages using java script:

The following code is for  print webpages using javascript

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


The text in red is a JavaScript method. It looks like target link. But it is directing the link for print page dialog box. When we click the image (print.gif) the print dialog box will appear.

 from the printing dialog box we can select no of copies, print pages range and order of printing etc.
another simple method using button control:

<form>
<input type="button" value="Print current page" onClick="window.print()">
</form>

  When we click the button  the print dialog box will appear. After choosing the options in the dialog box we can print the page

No comments:

Post a Comment