简体   繁体   English

Window.onblur - 禁用 iframe 事件

[英]Window.onblur - disable iframe event

I need to use some scripts after window.onblur event.我需要在 window.onblur 事件之后使用一些脚本。 But on my app i have Google Maps, which one is injected into iframe.但是在我的应用程序中,我有 Google 地图,其中一个被注入到 iframe 中。 Evervy click on iframe firing window.onblur(). Evervy 点击 iframe 触发 window.onblur()。 How to prevent this?如何防止这种情况?

You can prevent the default window.blur event if the original target of the event is the iframe.如果事件的原始目标是 iframe,您可以阻止默认的 window.blur 事件。

$(window).blur(function(event){
    if($(event.target).attr('id')== "myiframe"){
        event.preventDefault();
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM