title: Pass value to Child window using Javascript
body: <p>I'm attempting to get the <code>question id</code> from the parent page and pass it into my new child page. When the child window gets a response it will put this data into <code>text_body id</code>. I have managed to create the <code>question id</code> and open a new window. However, I get an error when passing the value to <code>text-body id</code>.</p>
  
  <blockquote>
    <p>Cannot set property 'value' of null.</p>
  </blockquote>
  
  <p>I think the problem happened because the JavaScript still detect the previous page, and can't focus into the new window. I have included my source code below.</p>
  
  <pre><code>function wait(ms){
      var start = new Date().getTime();
      var end = start;
      while(end &lt; start + ms) {
          end = new Date().getTime();
      }
  }
  
  var body = document.getElementById('question').innerText;
  alert(body);
  
  var k = window.open("http://testing/support");
  wait (2000);
  k.focus();
  wait (1000);
  k.focus();
  k.document.getElementById('text_body').value = body;
  </code></pre>