Printing DIVISION TAG contents using JavaScript.

Vishalneeraj-24503
Posted by Vishalneeraj-24503 under JavaScript category on | Points: 40 | Views : 169
Below Javascript code is used for printing Div Tag contents:-
<head>
<title></title>
<script type="text/javascript">
function Print_Div_Contents() {
var divContents = document.getElementById("dv_contents").innerHTML;
var print_window = window.open('', '', 'height = 250,width = 430');
print_window.document.write('<html><head><title>DIV Contents</title>');
print_window.document.write('</head><body >');
print_window.document.write(divContents);
print_window.document.write('</body></html>');
print_window.document.close();
print_window.print();
}
</script>
</head>

<div id = "dv_contents" style = "border: 1px dotted black; padding:5px; width: 300px">
<span style = "font-size: 10pt; font-weight: bold; font-family: Arial">Hello,
<br />
This is <span style="color: #0090CB">DotNetFunda.com website</span>.<br />
DotNetFunda.com</span>
</div>
<br />
<input type = "button" onclick = "Print_Div_Contents();" value = "Print" />

Comments or Responses

Login to post response