简体   繁体   中英

Codename One UWP browser execute issue

I am trying to obtain the HTML contents of a BrowserComponent in CodenameOne by using this code:

browserComponent.executeAndReturnString("document.documentElement.outerHTML")

This works in the simulator, on iOS and on Android. In a UWP app executeAndReturnString never returns. Here is a runnable example (use in the start method of a new project):

BrowserComponent browserComponent = new BrowserComponent();
browserComponent.addWebEventListener(BrowserComponent.onLoad, evt -> {
    Log.p("onLoad start", Log.INFO);
    Log.p(browserComponent.executeAndReturnString("document.documentElement.outerHTML"), Log.INFO);
    Log.p("onLoad end", Log.INFO);
});

Form form = new Form("Browser Contents Test", new BorderLayout());
form.add(BorderLayout.CENTER, browserComponent);
form.show();

browserComponent.setURL("http://www.codenameone.com");

In a UWP app this is everything in the log:

[EDT] 0:0:1,837 - Codename One revisions: 7dd4e7d08b3442d90959477ee52a5ae8c4361b29
 
[EDT] 0:0:1,891 - onLoad start

I have tried the asynchronous BrowserComponent.execute methods and they do the same thing. Can anyone help me?

The executeAndReturnString issue has now been fixed. There was an additional issue that there is a limit on the length of the returned string. That is not fixed yet but it can be worked around with code like this:

browserComponent.executeAndReturnString("document.documentElement.outerHTML.substring(0, 1000)")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM