0

How to make call of Firemonkey code (callback) from JavaScript code in TTMSFMXWebBrowser?

I can perform JavaScript code from Firemonkey, but how I can make a callback or call Firemonkey code/event from JavaScript?

Is it possible?

0

2 Answers 2

0

So in the URL you can pass a custom string or whatever data like this:

myurl://dostuff?a=b&c=d

if (Copy(S, 1, 8)='myurl://') then
begin
// now you know it is a callback and not a real URL
// if it is a callback you can cancel the load using the below code
// and then process the callback
end;

TWebBrowser:

procedure TForm2.WebBrowser1ShouldStartLoadWithRequest(ASender: TObject;
  const URL: string);
begin
// check URL and
WebBrowser1.Stop;
end;

TTMSFMXWebBrowser:

procedure TForm2.TMSFMXWebBrowser1BeforeNavigate(Sender: TObject;
var Params: TTMSFMXCustomWebBrowserBeforeNavigateParams);
begin
// Get your result from Params.URL and cancel via Params.Cancel := True;
end;
Sign up to request clarification or add additional context in comments.

Comments

-1

You should try Google before you ask ...

Firemonkey WebBrowser is a wrapper and it depends on platform.

Check this example for TWebBrowser on Windows
http://www.delphidabbler.com/articles?article=22&part=1

As WebBrowser is a wrapper, it does not expose all functions. You have to modify it a little for your purposes.

You can also check these topics
Callback Delphi function from TWebBrowser by javascript on Delphi XE6 for all platforms (including iOS, ANDROID)?
http://delphi.radsoft.com.au/2013/11/adding-javascript-processing-capability-to-twebbrowser-in-ios/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.