Missing references in html2 webview

Hi,

I am building GUI components around wx/html2/webview. I’m doing this with Python 2.7, wx 4.0.0b2, and I am testing on Windows 10.

I want to be able to load the WebView with data content from Python using SetPage.

To test I have a basic html/javascript web page in a utf-8 encoded file. I load the data from the file directly into WebView.SetPage, and I test the same data using MS Edge with the file URI. Everything is local to my desktop PC.

On the surface it works beautifully, with CSS and HTML I get the same results via both methods and they fully work. However once I start trying to write JavaScript I immediately see that there are references that Edge knows about that WebView does not, even though WebView seems to be using the Edge back end.

The first example where I see this fail is

This works fine in Edge with no additional script links, but WebView complains “WebSocket is undefined”. Trying to inline these missing references quickly leads to cascading problems.

Can someone please explain why there is a difference in the runtime env between the two, and also is it actually feasible to write complex JavaScript or use off-the-shelf JS libs when using this method? (I haven’t seen a lot of examples online), and if not, what recommendations does anyone have for a better approach?

Many Thanks.

I am not super familiar with the WebView implementation for Windows, but I believe that it uses the IE backend (perhaps an older version).

Scott

···

On Tue, 13 Feb 2018, tvonnardroff@parhelion.ky wrote:

Hi,
I am building GUI components around wx/html2/webview. I'm doing this with
Python 2.7, wx 4.0.0b2, and I am testing on Windows 10.

I want to be able to load the WebView with data content from Python using
SetPage.

To test I have a basic html/javascript web page in a utf-8 encoded file. I
load the data from the file directly into WebView.SetPage, and I test the
same data using MS Edge with the file URI. Everything is local to my
desktop PC.

On the surface it works beautifully, with CSS and HTML I get the same
results via both methods and they fully work. However once I start trying
to write JavaScript I immediately see that there are references that Edge
knows about that WebView does not, even though WebView *seems* to be using
the Edge back end.

The first example where I see this fail is <script>var ws = new
WebSocket(...)</script>

This works fine in Edge with no additional script links, but WebView
complains "WebSocket is undefined". Trying to inline these missing
references quickly leads to cascading problems.

Can someone please explain why there is a difference in the runtime env
between the two, and also is it actually feasible to write complex
JavaScript or use off-the-shelf JS libs when using this method? (I haven't
seen a lot of examples online), and if not, what recommendations does
anyone have for a better approach?