允许webviewA在webviewB中打开内容
webviewA.getEngine().setCreatePopupHandler(new Callback<PopupFeatures, WebEngine>() {
@Override public WebEngine call(PopupFeatures popupFeatures) {
return webviewB.getEngine();
}
});
Run Code Online (Sandbox Code Playgroud)
或者,如果您使用的是jdk8并且不喜欢打字:
webviewA.getEngine().setCreatePopupHandler(
popupFeatures -> webviewB.getEngine()
);
Run Code Online (Sandbox Code Playgroud)
使您的HTML链接在新窗口中打开内容
定义webviewA使用中加载的文档中的超链接target="_blank"
例如:
webviewA.loadContent(
"<a href='http://sundae.triumf.ca/pub2/cave/node001.html' target='_blank'>" +
"XYZZY" +
"</a>"
);
Run Code Online (Sandbox Code Playgroud)
当你点击超链接并说出魔法字时,它将打开巨大的洞穴冒险webviewB.