在不知道子弹出窗口句柄名称的情况下如何访问它们?

发布于 2024-08-09 06:25:08 字数 87 浏览 8 评论 0原文

我试图查看正在打开哪些窗口,但我不知道它们的名称。

如何在 JAVASCRIPT/DOM/或 JQUERY 中访问它们?

谢谢!

I'm trying to see which windows are being opened, but I dont know the window names as they are called.

How can I access them in JAVASCRIPT/DOM/or JQUERY?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

朱染 2024-08-16 06:25:08

我见过的每个例子都需要窗口的名称。如果您自己无法控制,因为您正在使用复杂/混淆的库或复杂网站的通用油脂猴脚本,那么您可以尝试 猴子补丁 窗口打开的位置。假设所有窗口都是通过 window.open 打开的,您可以这样做:

var allWindows = []
var _windowOpen = window.open;
window.open = function() {
  var newWindow = _windowOpen.apply(this, arguments);
  allWindows.push(newWindow);
}

allWindows 将包含迄今为止已打开的所有窗口的列表。您可以随时循环浏览它们并检查“已关闭”属性以查找仍处于打开状态的属性。即如果 !win.close 则推断窗口已打开。

Every example I've seen requires the name of the window. If you can't control that yourself, because you're using a complicated/obfuscated library or a generic greasemonkey script for a complicated website, say, you could try and monkey patch the places the window is opened. Assuming windows are all opened via window.open, you could do:

var allWindows = []
var _windowOpen = window.open;
window.open = function() {
  var newWindow = _windowOpen.apply(this, arguments);
  allWindows.push(newWindow);
}

allWindows will then contain the list of all windows that have been opened so far. You can loop through them at any time and check the "closed" property to find those that are still open. i.e. you deduce a window is open if !win.closed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文