aspvbnetnerd
Programmer
When I click on the link to print. A new window is opened but onload="window.print();" is never happened.
But If click F5 then the printers is loaded.
I tried to add
to printContent function but it doesnt work
Can anyone please help me?
link, if you wanna se the problem
George
But If click F5 then the printers is loaded.
Code:
<html>
<head>
<script type="text/javascript">
function printContent(id){
str=document.getElementById(id).innerHTML
newwin=window.open('','printwin','left=100,top=100,width=400,height=400')
newwin.document.write('<HTML>\n<HEAD>\n')
newwin.document.write('<title>Print Page</title>\n')
newwin.document.write('</HEAD>\n')
newwin.document.write('<BODY onload="window.print();">\n')
newwin.document.write(str)
newwin.document.write('<a href="#" onClick="window.print();">Print</a>')
newwin.document.write('</BODY>\n')
newwin.document.write('</HTML>\n')
}
</script>
</head>
<body>
<div id="print_div1" style="border:1px solid #000000">
Only the contents of this div are printed.
I have used a border to highlight the printable content.
Item One
Item Two
</div>
<a href="#null" onclick="printContent('print_div1')">Click to print div 1</a>
</body>
</html>
I tried to add
Code:
newwin.document.write('<a href="#" onClick="window.print();">Print</a>')
Can anyone please help me?
link, if you wanna se the problem
George