We help IT Professionals succeed at work.

leaving iframe event

pamela rizk
pamela rizk asked
on
55 Views
Last Modified: 2018-06-23
is there any way to catch event when leaving  iframe ?
Comment
Watch Question

Steven KribbeSoftware Engineer

Commented:
You can detect the loss of the focus of an iframe with this small piece of jQuerycode:

$(document).focusout( function(){
       setTimeout(function() {
       // used setTimeout to make sure the event is passing the event loop and call your logic as well
       if (document.activeElement instanceof HTMLIFrameElement) {
             // do stuff
        }
    },0);
});
Developer
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
pamela rizkDeveloper

Author

Commented:
this solution worked!