0

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.

5
  • I am getting it in firefox 19.0, which browser? Commented Feb 28, 2013 at 4:19
  • it's working.check in chrome. Commented Feb 28, 2013 at 4:19
  • I am doing it in IE8 :( Commented Feb 28, 2013 at 4:21
  • I tried out this on IE7/8 and it's working fine for me. Commented Feb 28, 2013 at 4:28
  • ohkay dont know whats going wrong in here Commented Feb 28, 2013 at 6:58

2 Answers 2

2

Try 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>

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.