0

i have 2 iframe(embed) element. Trying to show an alert window before playing the video, but no alert window showing. This is what i'm trying to do.

this is html (2 iframe)

<iframe width="450" height="253" src="https://www.youtube.com/embed/ROtv13CqjzU?feature=oembed" frameborder="0" allowfullscreen="" style="width: 100%; height: 100%; z-index: 1; position: relative;" __idm_id__="490590210"></iframe>
<iframe src="https://player.vimeo.com/video/235638223" width="450" height="190" frameborder="0" title="AUTOMATICA - Robots Vs. Music - Nigel Stanford" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen="" style="width: 100%; height: 100%; z-index: 1; position: relative;"
__idm_id__="490590209"></iframe>

this is js

var iframee = document.querySelectorAll("iframe");
iframee[0].onclick = function(){
alert(this);
}

any idea how to do this?

  • 2
    Possible duplicate of [Add click event to iframe](https://stackoverflow.com/questions/15080222/add-click-event-to-iframe) – Kevin Kloet Oct 03 '17 at 13:53
  • it's not working for embeded video, see here - http://jsfiddle.net/4HQc4/1847/ –  Oct 03 '17 at 14:08
  • detecting click event on external video's is not natively supported, [see this question](https://stackoverflow.com/questions/7260605/how-can-i-track-a-click-event-of-an-embedded-video-youtube-vimeo-etc-to-t) – Kevin Kloet Oct 03 '17 at 14:11

0 Answers0