简体   繁体   English

在外部窗口的新窗口(window.open)中的onclose / onunload

[英]onclose/onunload in a new window (window.open) for external url

Is there any way to capture the event onclose of the window? 有什么办法可以在窗口关闭时捕获事件? I am trying to auth the user on twitter with a popup. 我正在尝试通过弹出窗口在Twitter上对用户进行身份验证。 And I would like to reject the request/promise if the user close the window. 如果用户关闭窗口,我想拒绝请求/承诺。

The problem is onclose does not exists and onunload works on urls of the same domain. 问题是onclose不存在,并且onunload可在相同域的url上工作。 I have tried an iframe, but twitter do not allow that. 我已经尝试过iframe,但是Twitter不允许这样做。

No., There is no event for capturing window close event. 不,没有捕获窗口关闭事件的事件。

Try using window.unload(function(){}) in the current page. 尝试在当前页面中使用window.unload(function(){})

above event triggered while refreshing the page or navigating from the current page. 刷新页面或从当前页面导航时触发上述事件。

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

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