HTMLViewer and localstorage

I’m working on an app which has a JavasScript/HTML component which will be run in Xojo HTMLViewers, as well as possibly in a standalone mode (just HTML in Safari or IE11). I’d like the code to be as simple as possible.

It seems like the JavaScript localstorage object is not retained when running inside a Xojo HTMLViewer on macOS.

Perhaps a related issue : is Xojo using the older WebView or the newer WKWebview control?

This would be a 64 bit macOS buld using the latest Xojo.

Yes, it’s currently a WebView.

I just did a test using two windows, using Xojo 2018R3 and a 64 bit macOS build:

Each window executes a simple script to either set or get data from localstorage:

log("Get from localstorage");
var id = "foobar";
var json=null;
try {
  json = localStorage.getItem(id);
} catch(err) {
   log("exception during localStorage.getItem");
log("j=" + json);
log("localStorage.getItem success");


  • for both windows, getting and setting data to localstorage is persistent while the app is running, and data can be shared across multiple instances of the window (e.g. set data in a HTMLViewer in Window1, and it can be retrieved from a HTMLViewer in Window2)
  • the two styles (WebView, WKWebView) don’t share data : set localstorage in one type, and it’s not visible in the other
  • Data stored in HTMLViewer (WebView) is not persistent - once you quit the app and restart it, the data goes to null.
  • Data stored in MBSPlugin (WKWebView) is persistent - once you quit the app and restart it, the data is still there.