title: Escape iframe with javascript
body: <p>I know how to escape the iframe. I have a link:</p>
  
  <pre><code>&lt;a id="aaa" href="http://localhost/projectManagement/users" target="_parent" &gt;Sign up&lt;/a&gt;
  </code></pre>
  
  <h2>by clicking on that link I will escape the iframe</h2>
  
  <p>the problem is that I want to escape the iframe when clicking on a button not a link. </p>
  
  <p>I know how to execute JavaScript with the click of a button so I have been working on executing that link with javascriopt</p>
  
  <p>things I have tried out:</p>
  
  <p>html:  (it is inside a iframe)</p>
  
  <pre><code>&lt;button onClick="tempEvent();" style="width: 500px; height: 50px; margin-top: -15px; font-size: 20px;"&gt;
        &lt;b&gt;
            click me              
         &lt;/b&gt;
  &lt;/button&gt;
  &lt;div style="height: 15px;"&gt;
  &lt;/div&gt;
  &lt;a id="aaa" href="http://localhost/projectManagement/users" target="_parent" &gt;Sign up&lt;/a&gt;
  </code></pre>
  
  <p>JavaScript</p>
  
  <pre><code>&lt;script&gt;
      function tempEvent()
      {
  
          clickLink(document.getElementById('aaa'));  // this technique does not work on firefox!
          fireEvent(document.getElementById("aaa"),'click'); // this technique does not work in firefox eather.
  
          document.getElementById("aaa").onclick(); 
      }
  
      function clickLink(link) {
          if (document.createEvent) {
              var event = document.createEvent("MouseEvents");
              event.initMouseEvent("click", true, true, window,
                  0, 0, 0, 0, 0,
                  false, false, false, false,
                  0, null);
              link.dispatchEvent(event);
          }
          else if (link.fireEvent) {
             link.fireEvent("onclick");
          }
      }
  
      function fireEvent(obj,evt){    
          var fireOnThis = obj;
          if( document.createEvent ) {
            var evObj = document.createEvent('MouseEvents');
            evObj.initEvent( evt, true, false );
            fireOnThis.dispatchEvent(evObj);
          } else if( document.createEventObject ) {
            fireOnThis.fireEvent('on'+evt);
          }
      }
  
  
  
  &lt;/script&gt;
  </code></pre>
  
  <p>I know I can replace the button with the link but I am just dont understand why I cannot achieve this!</p>
  
  <h2>edit</h2>
  
  <p>Even if I place the link inside the button it does not work!</p>