Mutliple variables to a funciton with runJavaScript

I’m wondering if anyone has been able to get function calls with more than one var in the signature to accept input from runJavaScript.

I have funcional communication between a WebView and html / js but can’t seem to get past this kind of evil:

webview.runJavaScript("return latlon('" + lat + "," +lon + "')")

this is obviously bogus.

But, it also just seems ‘flaky’.

You are asking about functions with “more than one var in the signature”. I assume that with “var” you mean “parameter”? Your code on the other hand seems to be calling a function with just one parameter. If lat = 123 and lon = 456, your code would be calling latlon('123,456'). Perhaps you were supposed to write:

webview.runJavaScript("return latlon('" + lat + "','" + lon + "')")

?

1 Like

Thanks! That was it. Yes, variable parameter. I conflate the variable and const. :slight_smile: And I need bifocal lenses.

Now if I could find a way to run that at after initialization. Is this a correct usage if one wants some initial action?

            onViewInitialized: {
                webview.loadFrameScript(Qt.resolvedUrl("../html/framescript.js"));
                webview.addMessageListener("webview:action");
                webview.runJavaScript("return init('" + lat + "','" + lon + "')");
            }