Callback Delphi function from TWebBrowser by javascript on Delphi XE6 for all platforms (including iOS, ANDROID)?

后端 未结 3 567
轮回少年
轮回少年 2020-12-20 18:03

I need create an application on Delphi XE6 for Android and iOS. This application mest be use a TWebBrowser to show Google Maps, then I need \"send\" from Delphi to javascrip

3条回答
  •  既然无缘
    2020-12-20 18:30

    With JavaScript it is very common to access HTTP servers, for example over jQuery. If you can make your Delphi code available over HTTP, either as a local serveror on the web, your JavaScript code can invoke Delphi code by sending a HTTP request, and receive data from Delphi functions as a HTTP response.

    Another option are WebSockets. They are an extension of HTTP, work asynchronously so the Delphi server can send data to the script - without having to wait for a request first (known as server push / Comet).

    This would be a standards-based, widely used solution, which does not rely on a particular web client. The free open source library Internet Direct (Indy) can be used on all supported platforms to create HTTP servers, stand-alone or integrated with your application.

    Other protocols which are availabe for communication between JavaScript and servers might be also worth a look, for example STOMP.

    For your specific function, the HTTP call could use a GET request with parameters:

    http://localhost/JSFeekback?par1=val1&par2=val2&par3=val3&par4=val4
    

提交回复
热议问题