简体   繁体   English

如何根据其标题选择特定的窗口

[英]How to choose a specific window based on its title

I want to choose a specific window, and perform operations on that window- I will pass that window as a parameter to another function which does the work... 我想选择一个特定的窗口,然后对该窗口执行操作-我会将那个窗口作为参数传递给另一个起作用的函数...

I know beforehand, that the title of the windows is (for example) "XYZ" 我事先知道,窗口的标题是(例如)“ XYZ”

How do I select the window in browser with that title? 如何在浏览器中选择带有该标题的窗口?

I found that in javascript there are ways to assign a title to a window, but I couldnt find a way to search for and find the window which has a specific title. 我发现在javascript中,有一些方法可以为窗口分配标题,但是我无法找到一种方法来搜索并找到具有特定标题的窗口。

You cannot select other windows, unless you've already got a reference to it. 您不能选择其他窗口,除非您已经对其进行了引用。

There are two methods to get a reference: 有两种方法可以获取参考:

  • The window.opener property holds a reference to the window which opened the current one. window.opener属性保存对打开当前窗口的窗口的引用。
  • Saving the return value of window.open() also offers a reference. 保存window.open()的返回值也提供了参考。

Each reference to another window will be a window object. 对另一个窗口的每个引用将是一个window对象。 window.document.title can be used to read the value of the title. window.document.title可用于读取标题的值。 (where window is the reference to the other window). (其中window是对另一个窗口的引用)。

Cross-domain restrictions will prevent other windows from being read, though. 但是,跨域限制将阻止读取其他窗口。

See this answer to read the document/window object of embedded frames. 请参阅此答案以阅读嵌入式框架的文档/窗口对象。

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

相关问题 如何根据我在extjs中选择的文件设置窗口的标题 - how to set window's title according to a file i choose in extjs 如何基于时间在javascript或jQuery或angular中选择特定的列表行? - How to choose specific list line based on time in javascript or jQuery or angular? Chrome 扩展程序:如何根据标题刷新选项卡? - Chrome Extension: How to refresh a tab based on its title? 如何根据标题或 alt 向图像添加类/ID - How to add class/id to image based on its title or alt 如何在基于浏览器的`window.URL.createObjectURL()`和`window.webkitURL.createObjectURL()`之间进行选择 - How to choose between `window.URL.createObjectURL()` and `window.webkitURL.createObjectURL()` based on browser 如何在 d3 中选择特定的 SVG 并更改其属性? - How can I choose an specific SVG in d3 and change its attributes? 如何使用CasperJS根据其属性的一部分选择特定元素 - How to select specific element based on a part of its attribute with CasperJS 如何根据其唯一ID打开特定的嵌套引导程序 - How to open a specific nested bootstrap accordeon based on its unique id 函数及其选择器,用于选择如何导出CSV - Function and its selector to choose how to export CSV 如何在调整窗口大小时隐藏标题? - How to hide title on window resize?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM