[英]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.