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

iOS Webview not able to return an object

    XMLWordPrintable

Details

    • iOS/tvOS/watchOS

    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

            stromme Christian
            scorp1us Jason Hihn
            Votes:
            3 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes