title: Open a new page in a new window, print it and closed it
body: <p>I still can't get this code to work, I am trying to use the "onClick" to swap the image once clicked, open this new page in a new window, print this new opened window and closed it. It opens the new page on the new window, but it prints a blank page and it cant close it, it seems that the focus is not been set somehow. Can any one help me on tis? Thanks!</p>
  
  <pre><code>&lt;!DOCTYPE HTML&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8"&gt;
   &lt;title&gt;Print it&lt;/title&gt;
  &lt;!--style type="text/css" media="print"&gt; .noprint {visibility: hidden;} &lt;/style--&gt;
  &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  $(function(){
  $(".img-swap").live('click', function() {
  if ($(this).attr("class") == "img-swap") {
    this.src = this.src.replace("_off","_on");
  } else {
    this.src = this.src.replace("_on","_off");
  }
  $(this).toggleClass("on");
  });
  });
  &lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  // &lt;!--
  
   Popup = {
  
   init : function () {
   $('a.action_print').bind('click', Popup.printIt);
      },
  
       printIt : function () {
  
          var win = window.open('doc1.html','Printed','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=350,height=250');
  
          if (win) {
              win.document.close();
               win.focus();
              win.print();
          }
  
          return false;
      }
  }
  
  $(document).ready(function () {
      Popup.init();
  });
  
  
   // --&gt;
  &lt;/script&gt;
   &lt;/head&gt;
   &lt;body&gt;
  
   &lt;br&gt;
   CLick to Print:&lt;br&gt;&lt;br&gt;
  
  &lt;p style=" padding: 125px 0; text-align: center;"&gt;
  &lt;a class="action_print" target="Printed"&gt;&lt;img src="images/cam_off.png" class="img-swap" width="100" height="100" /&gt;&lt;/a&gt;
  &lt;/p&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Thanks for looking!</p>