Trigger click in cross-domain iFrame

I want to trigger a click event in a cross-domain iframe.

For videos, we use images as the cover for these frames. When the image is clicked, an iframe is loaded. There is no auto play feature in this video embed that can be used, so we need to click on the downloaded embedded file to start the video.

We want to click the image, load the embed video (iframe) and click the iframe again using jQuery.

+4
source share
2 answers
window.focus();//force focus on the currenct window; window.addEventListener('blur', function(e){ if(document.activeElement == document.getElementById('your_iframe_id')) { //do your stuff } }); $('your_iframe_id').mouseleave(function(){ window.focus(); });// double check when mouse out of iframe 
+1
source

This is the way to accomplish this:

 window.focus(); window.addEventListener('click', function(e){ if(document.activeElement == document.getElementById('ve-panel-iframe')) { alert(1); } }); 
0
source

Source: https://habr.com/ru/post/1469206/


All Articles