title: Move a popup window in JavaScript using setInterval
body: <p>I wrote the following code in JavaScript to open a popup window when a button is pressed, and then use setInterval to move the window every 2 seconds.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
   &lt;head&gt;
      &lt;meta charset = "utf-8"&gt;
      &lt;title&gt;  Javascriptin' Some Codes &lt;/title&gt;
      &lt;script&gt;
              function hi() {
              var printOut = window.open("http://www.google.com","_blank", 'height=200, width=200');
              setInterval(function() { printOut.moveBy(10,10);}, 2000)
              window.alert("hi");}
      &lt;/script&gt;
   &lt;/head&gt;
   &lt;body&gt;
      &lt;button onclick="hi()"&gt; Try me &lt;/button&gt;
   &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The window opens, but the setInterval doesn't appear to work- the window does not move after being launched. I was wondering why my code doesn't work, and what I could do to make it function the way I'd like it to.</p>