问题描述
我注意到,在使用Google Mail的Google Chat功能时,您可以在其自己的窗口中弹出聊天窗口。然后,当我关闭Google Mail窗口时,它警告说,如果我继续并显示窗口列表,则其他窗口也将被关闭。这是如何完成的?是否有可能跟踪你调用的窗口是否已关闭?
I noticed when using the Google Chat feature from your Google Mail that you can pop out a chat into its' own window. Then when I went to close the Google Mail window it warned that other windows would also be closed if I continued and then showed a list of the windows. How is this done? Is it possible to track whether a window you invoked has been closed?
推荐答案
是的,当你在JavaScript中执行window.open ,你可以将它设置为一个var:
Yes, when you do a window.open in JavaScript, you can set it to a var like:
myWindow = window.open(...)
然后,您可以将事件绑定到该窗口,如:
Then you could bind events to that window like:
myWindow.onUnload = funcWindowClosed;
您可以通过将多个弹出窗口放入数组中来跟踪多个弹出窗口。
You could keep track of multiple pop-up windows by putting them into an array.
您也可以使用以下方式在子窗口(弹出窗口)中调用父窗口中的JavaScript函数:
You can also call JavaScript functions in the parent window by the child (pop-up) window using:
window.opener
这篇关于浏览器如何或有可能跟踪弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!