Here is the simple page with a table. I want to print it on button click. But the script is not working.
<html><head><style>th{background-color:#000}table, th, td { border: 1px solid black; } </style></head><body><center>
<TABLE id=highlight class=hilite border=1 cellSpacing=5 cellPadding=4><THEAD style="COLOR: white">
<TR>
<TH colSpan=2>MINI STATEMENT</TH></TR></THEAD>
<TBODY>
<TR>
<TD class=row width="15%"><B>Account Id</B></TD>
<TD class=row><B>A000000003</B></TD></TR>
<TR></TR>
<TR>
<TD class=row width="15%">Your Previous Balance</TD>
<TD class=row width="15%">2539.62</TD></TR>
<TR></TR>
<TR>
<TD class=row width="15%">Your Current Balance</TD>
<TD class=row width="15%">2538.62 </TD></TR></TBODY></TABLE><input type='button' onClick='window.print()' value='Print'></center></body></html>
This is maintenance code of a dummy project so just ignore standards and conventions :p For practice.
Here is the simple page with a table. I want to print it on button click. But the script is not working.
<html><head><style>th{background-color:#000}table, th, td { border: 1px solid black; } </style></head><body><center>
<TABLE id=highlight class=hilite border=1 cellSpacing=5 cellPadding=4><THEAD style="COLOR: white">
<TR>
<TH colSpan=2>MINI STATEMENT</TH></TR></THEAD>
<TBODY>
<TR>
<TD class=row width="15%"><B>Account Id</B></TD>
<TD class=row><B>A000000003</B></TD></TR>
<TR></TR>
<TR>
<TD class=row width="15%">Your Previous Balance</TD>
<TD class=row width="15%">2539.62</TD></TR>
<TR></TR>
<TR>
<TD class=row width="15%">Your Current Balance</TD>
<TD class=row width="15%">2538.62 </TD></TR></TBODY></TABLE><input type='button' onClick='window.print()' value='Print'></center></body></html>
This is maintenance code of a dummy project so just ignore standards and conventions :p For practice.
Share Improve this question asked Feb 28, 2013 at 4:13 Mahesha999Mahesha999 25k30 gold badges130 silver badges210 bronze badges 5- I am getting it in firefox 19.0, which browser? – arjuncc Commented Feb 28, 2013 at 4:19
- it's working.check in chrome. – Amrendra Commented Feb 28, 2013 at 4:19
- I am doing it in IE8 :( – Mahesha999 Commented Feb 28, 2013 at 4:21
- I tried out this on IE7/8 and it's working fine for me. – Aditya Singh Commented Feb 28, 2013 at 4:28
- ohkay dont know whats going wrong in here – Mahesha999 Commented Feb 28, 2013 at 6:58
2 Answers
Reset to default 2Try like this...
<html>
<head>
<script type="text/javascript">
function openWin() {
var myWindow = window.open('', '', 'width=200,height=100');
myWindow.document.write("<p>This is 'myWindow'</p>");
myWindow.document.close();
myWindow.focus();
myWindow.print();
myWindow.close();
}
</script>
</head>
<body>
<input type="button" value="Open window" onclick="openWin()" />
</body>
</html>
Other possible solution: Adblock chrome extension seems be related if print frame appears only after others events like print again, refresh, etc. Remove the extension and try again.