title: Iframe onload event only after an anchor onclick
body: <p>Sample code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;iframe name="iframe_a" onload="alert('Thanks for the visit!');"&gt;&lt;/iframe&gt;
  &lt;a href="http://www.example.com/" target="iframe_a"&gt;Go!&lt;/a&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I'd like to see the alert message after clicking on the link and when the iframe finishes loading. But now it appears on the initial page load, too. How can I achieve it so it works in IE8+?</p>
  
  <p>Just came up with a simple solution:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;iframe id="iframe_a" name="iframe_a" onload="if(this.className=='active'){alert('Thanks for the visit!');};"&gt;&lt;/iframe&gt;
  &lt;a href="http://www.example.com/" target="iframe_a" onclick="document.getElementById('iframe_a').className='active';"&gt;Go!&lt;/a&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>