I want to open link in another web view control on clicking the hyperlinks in another web view in swing using Java FX
我想在另一个Web视图控件中打开链接,使用Java FX单击另一个Web视图中的超链接
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
实际上我在同一个屏幕上有两个Web视图控件A n B.单击a中的超链接时,应在B Web视图控件中打开新链接
1 个解决方案
#1
5
Allow webviewA to open content in webviewB
允许webviewA在webviewB中打开内容
使用setCreatePopupHandler:
webviewA.getEngine().setCreatePopupHandler(new Callback<PopupFeatures, WebEngine>() {
@Override public WebEngine call(PopupFeatures popupFeatures) {
return webviewB.getEngine();
}
});
Or, if you are using jdk8 and don't like typing:
或者,如果您使用的是jdk8并且不喜欢打字:
webviewA.getEngine().setCreatePopupHandler(
popupFeatures -> webviewB.getEngine()
);
Make your html links open content in a new window
使您的HTML链接在新窗口中打开内容
Define the hyperlinks in the document loaded in webviewA
using target="_blank"
使用target =“_ blank”定义webviewA中加载的文档中的超链接
For example:
例如:
webviewA.loadContent(
"<a href='http://sundae.triumf.ca/pub2/cave/node001.html' target='_blank'>" +
"XYZZY" +
"</a>"
);
when you click on the hyperlink and utter the magic word, it will open the Colossal Cave adventure in webviewB
.
当你点击超链接并说出神奇的单词时,它将在webviewB中打开Colossal Cave冒险。
#1
5
Allow webviewA to open content in webviewB
允许webviewA在webviewB中打开内容
使用setCreatePopupHandler:
webviewA.getEngine().setCreatePopupHandler(new Callback<PopupFeatures, WebEngine>() {
@Override public WebEngine call(PopupFeatures popupFeatures) {
return webviewB.getEngine();
}
});
Or, if you are using jdk8 and don't like typing:
或者,如果您使用的是jdk8并且不喜欢打字:
webviewA.getEngine().setCreatePopupHandler(
popupFeatures -> webviewB.getEngine()
);
Make your html links open content in a new window
使您的HTML链接在新窗口中打开内容
Define the hyperlinks in the document loaded in webviewA
using target="_blank"
使用target =“_ blank”定义webviewA中加载的文档中的超链接
For example:
例如:
webviewA.loadContent(
"<a href='http://sundae.triumf.ca/pub2/cave/node001.html' target='_blank'>" +
"XYZZY" +
"</a>"
);
when you click on the hyperlink and utter the magic word, it will open the Colossal Cave adventure in webviewB
.
当你点击超链接并说出神奇的单词时,它将在webviewB中打开Colossal Cave冒险。