Event handler for iframe loaded not firing
<p>I have an iframe in my HTML, and I want to be notified when it's fully loaded. I have this testcase:</p>

<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" &gt;
&lt;head&gt;
&lt;title&gt;Test&lt;/title&gt;

&lt;script language="javascript" type="text/javascript"&gt;
function addListener(el, type, func, capture) {
 if (el.addEventListener){
  el.addEventListener(type, func, capture); 
 } else if (el.attachEvent){
  el.attachEvent('on'+type, func);
 }
}
function addhandlers(frame) {
 addListener(frame, "load", function(e) { onDomLoaded(e); }, true);
}
function onDomLoaded(e) {
 alert("loaded");
}
&lt;/script&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;form action="#"&gt;
&lt;input type="button" value="Add handlers" onclick="addhandlers(window.frames[0]);" /&gt;
&lt;/form&gt;

&lt;iframe id="frm" height="300" src="test.htm" width="700"&gt;&lt;/iframe&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>The test.htm file is just a standard html file with a few regular  links to places.</p>

<p>First I click the Add Handlers button to add the listeners, then I click any link in test.htm inside the iframe. My expectation is that I get an alert, but nothing happens. Why, and how do I solve it? I'm currently looking for a solution that works in firefox and IE (but nothing happens in either browser).</p>
