title: Adding click event handler to iframe
body: <p>I want to handle <code>click</code> event on an <code>iframe</code> with a handler that gets the <code>iframe</code>’s id as parameter.</p>
  
  <p>I’m able to add an <code>onClick</code> event handler via JavaScript as follows and it works fine:</p>
  
  <pre><code>iframe.document.addEventListener('click', clic, false);
  </code></pre>
  
  <p>But in this case I’m unable to pass a parameter to <code>clic()</code>. I tried to print <code>this.id</code> in <code>clic()</code> but no result.</p>
  
  <p><code>onClick</code> HTML attribute does not work at all, the handler is not called.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script type="text/javascript"&gt;
  function def() {
      myFrame.document.designMode = 'on';
  }
  function clic(id) {
      alert(id);
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body onLoad="def()"&gt;
  &lt;iframe id="myFrame" border="0" onClick="clic(this.id)"&gt;&lt;/iframe&gt;
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>