我有一个 Java Applet,它与 Java 插件交互以在指定的浏览器窗口中显示文档(只是 URL):
public class TestApplet extends Applet {
@Override
public void init() {
super.init();
final JButton showButton = new JButton("Show Google!");
showButton.addActionListener(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
try {
getAppletContext().showDocument(new URL("http://google.com"), "Some Window Title");
} catch (MalformedURLException e1) {
e1.printStackTrace();
}
}
});
add(showButton);
}
}
这在历史上一直有效,但从 Java 7 和 Java 6u27 开始,该窗口无法在 Internet Explorer 中打开(在 IE 8 中测试)。如果我使用 _blank
作为窗口标题(目标)而不是 Google
,则窗口会正确打开(尽管每次都在新窗口中)。
我已经找到了这个已在 6u27 中修复的错误:
还有其他人经历过同样的行为吗?您是否找到了解决方法(除了使用“_blank”之外)?
编辑
更新了示例。我实际上并没有使用“Google”作为目标,而是使用“某些窗口标题”(抱歉!)。这个问题似乎是名称中带有空格的目标所特有的。
最佳答案
It seems like this problem is unique to targets with spaces in the name.
两种可能的解决方案:
- 将“”替换为“%20”
- 不要在目标名称中使用空格!(尽管我认为这“不费吹灰之力”。)
关于java - showDocument() 在使用 Java 7/Java 6u27 的 IE8 中不显示新窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7809669/