title: using window.open with window.name
body: <p>The browser window.open method provides a way to access open windows by name. For example, <h3>window A:</h3></p>
  
  <pre><code>window.open('','myWindowName')
  </code></pre>
  
  <p>This will open a blank window B with window.name == 'myWindowName'. Then, </p>
  
  <h3>window C:</h3>
  
  <pre><code>window.open('http://example.com', 'myWindowName')
  </code></pre>
  
  <p>This will open example.com in window B.</p>
  
  <h2>The problem:</h2>
  
  <p>Rather than creating a new window with name == 'myWindowName', how can I set the name of an already opened window so that it can be accessed by other windows using window.open? Using Chrome the following does not work:</p>
  
  <h3>1. open the following html in the target window</h3>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;script&gt;window.name='myWindowName'&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
      target window
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>executing window.name in the target window now produces 'myWindowName'</p>
  
  <h3>2. execute the following js from the console of another window</h3>
  
  <pre><code>window.open('http://example.com', 'myWindowName')
  </code></pre>
  
  <p>The code above opens example.com in a new window (also with window.name 'myWindowName') rather than the target window.</p>
  
  <h3>edit:</h3>
  
  <p>for some reason, in chrome, setting the name in the target window will work if no content is loaded into the window, but once content is loaded setting window.name no longer affects the window.open of other windows.</p>