In my JavaFX application, I have a WebView to load HTML contents. Is there a way to pass Javascript variables and manipulate it in JavaFX App. Let's say I have a variable FULLNAME
in Javascript and I want to display it in a TextField in JavaFX. Is it possible? Can you give an example.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
It is possible - assuming your webview is in a webView
variable, and you want your FULLNAME
variable loaded into fullNameField
, try executing this on the Java side:
String fullName = (String) webview1.getEngine().executeScript("FULLNAME;");
fullNameField.setText(fullName);