1

I'm trying to save some values in the LocalStorage of WebView of JavaFX. Is it supported by WebView? About html5test.com, the LocalStorage is enabled, but I don't find any solution to save data with Javascript in the LocalStorage.

  • AFAIK 'coockies' (which the local storage basically is) and the javafx webview (or java in general) are not a perfect combination. Look at [this question](https://stackoverflow.com/questions/45827482/access-all-the-cookies-from-a-javafx-webview) for example. Unfortunatly there are many more simular questions both related and unrelated to the javafx webview, all without a good solution or workaround. – n247s Nov 04 '18 at 20:48

1 Answers1

0

you can use this:

JSObject js = (JSObject)webEngine.executeScript("localStorage");

for example, in local storage, we have refreshTime with the value 1000.

for getting

println(js.getMember("refreshTime")) // print 1000

for setting

js.setMember("refreshTime",2000)

JSObject from import netscape.javascript.JSObject;

Rasoul Miri
  • 7,206
  • 57
  • 67