title: open an image in second page using javascript
body: <p>I have a button in <strong><code>index.html</code></strong>. after click on this button, I want to <em>append</em> an image in body section of <strong><code>page2</code></strong>. The following code only opens <strong><code>page2</code></strong> but the rest of code doesn't work. What I am doing wrong? thanks </p>
  
  <pre><code>function ready()
  {
      var w    = window.open("Page2.html");
      w.onload = function(){
          var p = document.createElement("img");
          x.setAttribute("src", "ts_WWW_2016w03.jpg");
          x.setAttribute("width", "304");
          x.setAttribute("height", "228");
          w.document.body.appendChild(p);
      };
  }
  </code></pre>