Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-70166

iOS Webview not able to return an object

    XMLWordPrintable

Details

    • iOS/tvOS/watchOS
    • b1e326ddf (dev), 3c3f58131 (6.8), 4c1303a51 (6.7), d143f74e8 (tqtc/lts-6.5)

    Description

      When using runJavaScript, the iOS version cannot return an object, while Android and OSX can.

       

      import QtQuick 2.11
      import QtQuick.Window 2.11
      import QtWebView 1.1
      
      Window {
      	visible: true
      	width: 640
      	height: 480
      	title: qsTr("Hello World")
      	property string html: "<html><script>var testResult={key: 'I exist!'};</script><body><canvas></canvas></body></html>";
      	Component.onCompleted: {
      		webview.loadHtml(html, '');
      	}
      	Timer {
      		id: testTimer
      		interval: 1000
      		repeat:false
      		running: false
      		onTriggered: {
      			webview.runJavaScript("try {testResult} catch (e) {'undefined'}", function (result) {
      				console.log('object', JSON.stringify(result));
      			});
      			webview.runJavaScript("try {JSON.stringify(testResult)} catch (e) {'undefined'}", function (result) {
      				console.log('stringified', JSON.stringify(result));
      			});
      
      		}
      		onRunningChanged: console.log('running', running);
      	}
      
      	WebView {
      		id: webview
      		anchors.fill: parent
      		onLoadProgressChanged: {
      			console.log('loadProgress', loadProgress)
      			if (loadProgress == 100) testTimer.running = true;
      		}
      	}
      }

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            vestbo Tor Arne Vestbø
            scorp1us Jason Hihn
            Votes:
            3 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: