JSFiddle - React, Tailwind, and code Playground

HTML

<iframe src="https://www.youtube.com/embed/Og2iXhOcE6Y" height="350px" width="650px" data-id="sdefregtJKB" id="iframe"></iframe>

JavaScript

focus();
var listener = window.addEventListener('blur', function() {
    if (document.activeElement === document.getElementById('iframe')) {
        // clicked
        alert("clicked");
    }
    window.removeEventListener('blur', listener);
});