简体   繁体   English

在Javascript中,如何重用先前由另一个页面打开的窗口

[英]In Javascript, how to reuse a window previously opened by another page

I have a window which uses javascript to open another child window, in the standard window.open("http://foobar","name") manner. 我有一个窗口,该窗口使用javascript以标准window.open("http://foobar","name")方式打开另一个子窗口。 If I open again with the same name, it reuses the window. 如果我再次使用相同的名称打开,它将重复使用该窗口。 This is great and exactly what I want. 这很棒,正是我想要的。

However, if the original window is closed, I would like to be able to reopen it and have its window.open go to the previously opened child window. 但是,如果原始窗口关闭了,我希望能够重新打开它并使它的window.open转到先前打开的子窗口。 Unfortunately, because it is a new parent window it will open another child window (which it will happily and correctly reuse). 不幸的是,由于它是一个新的父窗口,它将打开另一个子窗口(它将很高兴并正确地重用)。

Does anybody here know of a way to get hold of that previous child window so I can avoid making more windows than necessary? 在座的任何人都知道掌握前一个子窗口的方法,这样我就可以避免制作不必要的更多窗口?

Behind the scenes, the driver of this question is this: I have a java program which will periodically open different websites and I do not want to force a plethora of tabs or windows. 在后台,这个问题的驱动因素是:我有一个Java程序,它将定期打开不同的网站,并且我不想强制使用过多的选项卡或窗口。 Command-line options do not let you reuse windows or declare targets; 命令行选项不允许您重用Windows或声明目标。 javascript lets you declare a target. javascript让您声明目标。 I figured I would write a small javascript page which opened a page in a specifically-named window and then close itself. 我以为我会写一个小的javascript页面,在一个专门命名的窗口中打开一个页面,然后关闭自身。 Anytime you want to see a new page, hit that page passing in your new page.... Much to my dismay, though, targets seem specific to the window which creates them. 每当您想看到一个新页面时,都可以通过该页面传递您的新页面。。尽管如此,令我非常沮丧的是,目标似乎特定于创建它们的窗口。

So if you have ideas which are relevant to my actual problem I'm interested too. 因此,如果您有与我的实际问题相关的想法,我也很感兴趣。

嵌入浏览器所花的时间少于尝试各种控制浏览器的时间。

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

相关问题 Javascript-在不重用以前打开的窗口的情况下打开新窗口 - Javascript- Open New Window Without Reusing Previously Opened One 如何使用window.open()专注于先前打开的窗口 - How to focus on a previously opened window using window.open() 如何检索以前打开的窗口的URL? - How can I retrieve the URL of a previously opened window? 查找以前由 window.open 打开的窗口 - Find window previously opened by window.open 我可以使用什么JavaScript代码在新窗口(而不是以前打开的窗口)中打开 - What JavaScript code can I use to open in a new window, and not the window I previously opened 如何在JavaScript中的同一窗口中重定向到另一个页面 - how to redirect to another page in same window in javascript 打开另一个窗口标签时,如何防止当前窗口标签页重新加载? - how to prevent current window tab page reload when another window tab is being opened? Javascript Window.Open如何从其他页面获取打开的子窗口 - Javascript Window.Open how to obtain the opened child window from a different page javascript可以检测窗口是否打开了另一个窗口? - Can javascript detect if a window has opened another window? 是否可以从新加载的页面将元素插入到先前打开的 window 文档中? - Is it possible from a newly loaded page to insert an element onto a previously opened window document?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM