How to load a webpage from a line of html code in a JavaFX web browser?

Does the JavaFX web viewer support loading a web page from a line of html code? My code is currently working as per scenario 1 below. However, I will need to split the webFile into two parts (top and bot), and then insert the html line between them. The end result is uploaded via webviewer. Please see No. 2 for my intentions (this does not work). Can anyone suggest how I can do this? Thanks!

1.

String webFileStr = (new File(webFile)).toURI().toURL().toString();
webEngine.load(webFileStr);

2.

String webStr = topSlice + data + botSlice;
webEngine.load(webStr);
+4
source share
1 answer

Use WebEngine.loadContent .

webView.getEngine().loadContent("<html>hello, world</html>", "text/html");

Javadoc Description:

. , , , - , URL (, SVG, , ). (String), . , , , HTML.

:

<base> - loadContent(String), html javascript webengine loadContent()?.

+6

All Articles