本文介绍了如何获取所有已打开的子窗口的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想获取所有已打开的子窗口的引用。有什么办法吗?我没有使用 child = window.open(....)
只使用 window.open(....)
并打开多个子窗口。
I want to get the references of all already opened child windows. is there any way? I am not using child = window.open(....)
just using window.open(....)
and opening multiple child windows.
推荐答案
如果您不想更改当前代码,可以直接覆盖 window.open()
function:
If you don't want to change your current code, you can simply override window.open()
function:
var openedWindows = [];
window._open = window.open; // saving original function
window.open = function(url,name,params){
openedWindows.push(window._open(url,name,params));
// you can store names also...
}
运行这个调用 window.open()
之前的代码。对打开的窗口的所有引用都将存储在 openedWindows
数组中。您可以在任何地方访问它们
Run this code before calling window.open()
. All the references to the opened windows will be stored in openedWindows
array. You can access them anywhere you want
这篇关于如何获取所有已打开的子窗口的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!