title: jQuery set iFrame onLoad attribute
body: <p>I need to trigger a function when the iframe loads a second time (the user clicks some link in the iframe). When the iframe page changes I can set the window location to the iframe src.</p>
  
  <p>What I thought would be best is to set an onLoad attribute on the iframe element after the first load. I guess I would need the live event to tell when the iframe has been created, since it's dynamic.</p>
  
  <p>This is what I had in mind:</p>
  
  <pre><code>$(document).ready(function() {
      $('#tenant_login').fancybox({type:'iframe'});
      $('#tenant_login').click(function() {
          $('#fancybox-frame').attr('onload', function() {
              window.location = $('#fancybox-iframe').attr('src');
          });
      });
  });
  </code></pre>
  
  <p>If it matters the iframe is not cross domain.</p>