Jump to content
MMSoft

Mouse cursor

Recommended Posts

3 hours ago, Dave Nottage said:

It appears Android's WebView does not like part of the JavaScript (it works on macOS and iOS). I'm looking into it

I discovered what the problem is: The "default" TWebBrowser implementation for Android uses loadUrl:

procedure TAndroidWebBrowserService.EvaluateJavaScript(const AJavaScript: string);
begin
  FWebView.loadUrl(StringToJString('javascript:' + AJavaScript));
  UpdateContentFromControl;
end;

Which I guess does not accept the JavaScript that I provided. In TWebBrowserExt, it uses the evaluateJavascript method:

procedure TPlatformWebBrowserExt.ExecuteJavaScript(const AJavaScript: string; const AHandler: TJavaScriptResultProc);
begin
  if FWebView <> nil then
    FWebView.evaluateJavascript(StringToJString(AJavaScript), CreateValueCallback(AHandler))
  else
    AHandler(cJavaScriptNullResult, -1);
end;

Which does work. I've now added a demo to the HowTo repository, which uses TWebBrowserExt, and it works on Android (as well as iOS and macOS)

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×