title: Disable OnBeforeUnload Event: How Do I Sent Javascript to a Cross Domain Iframe?
body: <p>I want to accomplish something very simple.
  I am referring to a website through an Iframe.</p>
  
  <p>The iframe has a function with invokes "onBeforeUnload".
  I want to DISABLE onbefore unload in the iframe, from my parent page.</p>
  
  <p>I have figured out how to do this on SAME domain, and on same page. However, how can I do this for cross domain?</p>
  
  <p>I will do anything it takes, no matter how complex, to make this work.</p>
  
  <pre><code>&lt;iframe src="http://www.domain.com" width="100%" height="500" id="iframe"&gt;&lt;/iframe&gt; 
  
  &lt;script type="text/javascript"&gt;
  
   $(document).ready(function () {
  
   $('#iframe').load( function() {
        alert('Load was performed.'); 
      document.getElementById('iframe').contentWindow.window.onbeforeunload=null; 
  //NOTE: DOESN'T WORK CROSS DOMAIN! 
      });
  
      window.onbeforeunload=null  //Disables onbeforeunload event on THIS page so long as it is AFTER the original onbeforeunload event
  
      });
  
  &lt;/script&gt;
  </code></pre>
  
  <p>Thank you!</p>