Why does this onClick event not work in an HTML iframe?
<p><strong>Problem</strong></p>

<p>I am trying to use an onClick event to register when a user has clicked on an iframe. Why doesn't this work?</p>

<p>Here is a <a href="https://jsfiddle.net/8wropLmb/13/" rel="nofollow">fiddle</a></p>

<p><strong>Code</strong></p>

<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;script&gt;

function myFunction() {
    document.getElementById("demo").innerHTML = "Hello World";
}
&lt;/script&gt;
&lt;/head&gt;

&lt;body onLoad="def()"&gt;
&lt;iframe id="myFrame" border="0" onclick="myFunction()"&gt;&lt;/iframe&gt;
&lt;p id="demo"&gt;&lt;/p&gt;

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