title: How to bind a function to click event on an embed
body: <p>I'm trying to bin a function to click event on an embed (flash file). But the problem is the support, so <strong>I'm looking for a cross-browser solution</strong>. The first thought was add the onclick attribute to the embed element but in <strong>Chrome</strong> (v. 59.0.3071.115) the click event is never fired, or the <strong>onclick is not working</strong>... </p>
  
  <p><strong>Code 1</strong>:</p>
  
  <pre><code>&lt;embed onclick='myFunction(myOpts)'
         class="item" 
         src="/file.swf"&gt;
  
  function myFunction(myOpts){
      console.log('is working!!!!');
  }
  </code></pre>
  
  <p>The above code is not working on Chrome. So, I was thinking in a new way to call this function on a click event: a parent div with the onclick attribute and fire the embed click with javascript (to play the Flash), this is the code: </p>
  
  <p><strong>Code 2</strong>:</p>
  
  <pre><code>&lt;embed onclick='myFunction(myOpts, event)'
         class="item" 
         src="/file.swf"&gt;
  
  function myFunction(myOpts, event){
      console.log('is working!!!!');
      event.target.getElementsByTagName('embed')[0].click();
  }
  </code></pre>
  
  <p>But the embed's click is never fired... So, my question: </p>
  
  <p><strong>Is there a way to call a function with the a click event on an embed? If the answer is yes, which is the best way to call a function without affecting his behavior?</strong></p>