title: Bind .unload() or .onbeforeunload() to dynamically created iframe
body: <p>I need to append a spinner every time the iframe unloads and clear them on iframe load. I tried to set <code>iframe.unload()</code> and <code>iframe.onbeforeunload()</code> but nothing working. Here is my code block,</p>
  
  <pre><code>var iframe = $('&lt;iframe/&gt;'), $this = $('div#iframeContainer');
  iframe.attr('src', url).load(function() {
      alert('iframe onload!');
  }).unload(function() {
      alert("iframe unload");
  });
  $this.append(iframe);
  </code></pre>
  
  <p>The jQuery <code>.load()</code> works fine for me, but <code>.unload()</code> is never called. I even tried to bind the unload event to the <code>iframe.contents().find('body')</code>, but that too didn't work.</p>