我想在另一个 Web View 控件中打开链接,单击另一个 Web 中的超链接 使用 Java FX 在 swing 中查看
Actually i am having two web view controls A n B on the same screen . On clicking the hyperlink in a , new link should be opened in B web view control
最佳答案
允许webviewA打开webviewB中的内容
webviewA.getEngine().setCreatePopupHandler(new Callback<PopupFeatures, WebEngine>() {
@Override public WebEngine call(PopupFeatures popupFeatures) {
return webviewB.getEngine();
}
});
或者,如果您使用的是 jdk8 并且不喜欢打字:
webviewA.getEngine().setCreatePopupHandler(
popupFeatures -> webviewB.getEngine()
);
让您的 html 链接在新窗口中打开内容
使用 target="_blank"
定义加载到 webviewA
的文档中的超链接
例如:
webviewA.loadContent(
"<a href='http://sundae.triumf.ca/pub2/cave/node001.html' target='_blank'>" +
"XYZZY" +
"</a>"
);
当您单击超链接并说出魔法词时,它将在 webviewB
中打开 Colossal Cave 冒险。
关于java - 在另一个 Web View 控件中打开超链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13697974/