title: How to change iframe parent (top) location to url relative to iframe in IE with JavaScript?
body: <p><strong>exampleA.com</strong></p>
  
  <pre><code>&lt;iframe src="http://exampleB.com/"&gt;
  </code></pre>
  
  <p><strong>exampleB.com</strong></p>
  
  <pre><code>&lt;button onclick="top.location='/test'"&gt;Test&lt;/button&gt;
  </code></pre>
  
  <p>In Chrome (and I assume most browsers), clicking on the "Test" button inside the iframe changes the parent page to <code>exampleB.com/test</code>,  but in IE it sets the location relative to the parent URL (<code>exampleA.com/test</code>).</p>
  
  <p><strong>How can I make the test button work in all browsers with a URL relative to the iframe?</strong></p>
  
  <hr>
  
  <p><strong>NOTE</strong>:</p>
  
  <p>This can be done in HTML like:  <code>&lt;a href="/test" target="top"&gt;Test&lt;/a&gt;</code> as mentioned in the comments. See <a href="https://stackoverflow.com/questions/11207900/change-parent-url-from-iframe/11208032">this question</a>.</p>
  
  <p>However, I need(ed) a JavaScript-based solution for the parent location to be changed in reaction to an event, rather than a mouse click.</p>