Hi friends..
In this post am explain how to print webpage using javascript..
Ok lets come!
JAVA SCRIPT Page printing
If you want print webpage we can use window.print( ) method. This often used many more webpages. Some values retrieve database you make report java script page printing use to get report in printable document.
Syntax:
window.print( );
Example:
<html >
<head>
<script type="text/javascript">
function printDoc()
{
window.print();
}
</script>
<title>Untitled Document</title>
</head>
<body>
<div style="float:right">
<input type="submit" name="submit" value="PRINT" onclick="printDoc()" />
</div>
<table width="641" border="1" cellpadding="0" cellspacing="0" style="border:1x solid #3366CC" align="center">
<tr>
<td width="33" style="background-color:#00CC99; color:#CC0033">S.No</td>
<td width="118" style="background-color:#00CC99; color:#CC0033">Student Name</td>
<td width="121" style="background-color:#00CC99; color:#CC0033">Major</td>
<td width="157" style="background-color:#00CC99; color:#CC0033">Percentage</td>
<td width="178" style="background-color:#00CC99; color:#CC0033">Grade</td>
</tr>
<tr>
<td>1</td>
<td>Kathir</td>
<td>B.Sc IT </td>
<td>95%</td>
<td>A</td>
</tr>
<tr>
<td>2</td>
<td>Stalin</td>
<td>B.Com</td>
<td>90%</td>
<td>A</td>
</tr>
<tr>
<td>3</td>
<td>Francis</td>
<td>BBA</td>
<td>94%</td>
<td>A</td>
</tr>
<tr>
<td>4</td>
<td>Faruk</td>
<td>B.Sc Maths </td>
<td>94%</td>
<td>A</td>
</tr>
<tr>
<td>5</td>
<td>Karthick</td>
<td>B.Sc CS </td>
<td>92%</td>
<td>A</td>
</tr>
<tr>
<td>6</td>
<td>Siva</td>
<td>B.A </td>
<td>90%</td>
<td>A</td>
</tr>
<tr>
<td>7</td>
<td>Jegan</td>
<td>B.A</td>
<td>89%</td>
<td>B</td>
</tr>
<tr>
<td>8</td>
<td>Suresh</td>
<td>B.Sc IT </td>
<td>85%</td>
<td>B</td>
</tr>
<tr>
<td>9</td>
<td>Yuvraj</td>
<td>B.Sc Maths </td>
<td>84%</td>
<td>B</td>
</tr>
</table>
</body>
</html>
Output:
When print button clicked the print dialog opened like below fig
Done!
I hope its useful
Thanks
No comments:
Post a Comment