Printing a WebPage : Printing Entire Document and Print Specific Div

<html>
<head>
<title>Printing Web Page</title>
<script language=javascript>
function CallPrint(strid)
{
var prtContent = document.getElementById(strid);
var WinPrint = window.open(”,”,’letf=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0′);
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
prtContent.innerHTML=strOldOne;
}
</script>
</head>
<body>
<table>
<tr>
<td><strong>Printing entire document :</strong></td>
<td></td>
</tr>
<tr>
<td><strong><a href="#" onclick=window.print(); class="sub">Print Entire Document</a></strong></td>
<td><strong><a href="#" onClick=window.close(); class="sub">Close Window</a></strong></td>
</tr>
</table>
<br>
<hr>
<br>
<div id="divPrint">
<p>
Printing Content in specific Div :
</p>
<table cellpadding="2" cellspacing="2" class="divPrint" border=1>
<tr>
<td>EmpID</td>
<td>EmpName</td>
</tr>
<tr>
<td>101</td>
<td>Sri</td>
</tr>
<tr>
<td>102</td>
<td>Ven</td>
</tr>
</table>
</div>
<br>
<input id="btnPrint" type="button" value="Print Specific Div" onclick="javascript:CallPrint(‘divPrint’);" />
</body>
</html>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s