$(window).blur event affecting Iframe

前端 未结 3 464
一整个雨季
一整个雨季 2020-12-16 04:17

I want to detect when the user leaves my page( e.g open a new tab) so I can stop a countdown. I did it using:

$(window).blur(function() {
 //stop countdown
}         


        
3条回答
  •  孤城傲影
    2020-12-16 05:12

    Because of the isolation of the iframe, clicking inside it counts as a blur for the parent. If the content of the iframe could be brought in with ajax, that would be a better option.

提交回复
热议问题