So it turns out if testResult is an object it does not work on iOS, but if it's a string (JSON.stringify()) it works.
https://bugreports.qt.io/browse/QTBUG-70166
Sent: Friday, August 24, 2018 at 9:44 AM
From: "Jason H" <jh...@gmx.com>
To: "Tony Rietwyk" <t...@rightsoft.com.au>
Cc: interest@qt-project.org
Subject: Re: [Interest] WebVuew::runJavaScript problems
From: "Jason H" <jh...@gmx.com>
To: "Tony Rietwyk" <t...@rightsoft.com.au>
Cc: interest@qt-project.org
Subject: Re: [Interest] WebVuew::runJavaScript problems
It works on Android... Yeah, all that stuff is fine.
It's a single-page test script that as soon as it is evaluated, testResult is set to a value. I wait ~60 seconds for this simple page to load and loadProgress was 100 almost instantly after setting the URL.
The issue is only on iOS, Android is fine. This seems to be an issue with iOS WebView...
Sent: Thursday, August 23, 2018 at 6:41 PM
From: "Tony Rietwyk" <t...@rightsoft.com.au>
To: interest@qt-project.org
Subject: Re: [Interest] WebVuew::runJavaScript problems
From: "Tony Rietwyk" <t...@rightsoft.com.au>
To: interest@qt-project.org
Subject: Re: [Interest] WebVuew::runJavaScript problems
Hi Jason,
When are you calling runJavaScript? How are you loading the page? How do you know that the page has finished loading? I suggest to listen for the loadingChanged signal and then do the processing there when the status is LoadSucceededStatus. I assume that you are calling QtWebView::initialize() during application startup?
Hope that helps, Tony
On 24/08/2018 8:57 AM, Jason H wrote:
So thanks to sugestiosof including a timestamp, that works.I'm happy everywhere except for iOS. When I try to get my testResult, on iOS it is ALWAYS 'undefined'. I'm now using:try {testResult} catch (e) {'undefined'}(where testResult is at top-level scope:var testResult = "incomplete";So I should at least get "incomplete". So what do I have to do to get testResult in iOS?Sent: Thursday, August 23, 2018 at 7:59 AM
From: "Jérôme Godbout" <godbo...@amotus.ca>
To: "Jason H" <jh...@gmx.com>
Cc: "interestqt-project.org" <interest@qt-project.org>
Subject: Re: [Interest] WebVuew::runJavaScript problemsyou can always add a request argument with current datetime to your request url, this avoid caching:even if you don't use the argument, it would not cache itOn 23 August 2018 at 00:58, Jason H <jh...@gmx.com> wrote:I think I'm also seeing a caching problem where the server is updated but I'm getting old html code. Can I invalidate the cache?
> Sent: Wednesday, August 22, 2018 at 10:56 PM
> From: "Jason H" <jh...@gmx.com>
> To: "interestqt-project.org" <interest@qt-project.org>
> Subject: [Interest] WebVuew::runJavaScript problems>
> I'm trying to load and get a variable that is changed by the page.
> webview.runJavaScript("testResult", function(result){
> console.log('webview result', result);
> });
>
> The html is
> <html>
> <script language ="_javascript_">
> var testResult="xxxx";
> </script>
> <body>
>
> </body>
> </html>
>
> But the output is:
> qml: webview result undefined
>
> What am I doing wrong?
> _______________________________________________
> Interest mailing list
> Interest@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest