communicate between Delphi and Browser

1,854 views
Skip to first unread message

ra...@numberworks.com

unread,
Feb 19, 2013, 5:41:57 PM2/19/13
to delphichrom...@googlegroups.com
When my HTML5 application quits I wouldlike to store data that is in turn picked up by my Delphi app so that the dat can be stored in the registry for other uses.

How do I pass information back and forth between my delphi app and the app runnin in the embedded browser?

I am stuck!


mtjs

unread,
Apr 5, 2013, 5:43:58 PM4/5/13
to delphichrom...@googlegroups.com
Hi,

Look for: 

  TTestExtension = class
    class function hello: string;
  end;

part in the guiclient example (and everywhere TTestExtension is used). This way you can create a chromium extension, which you can then use in your javascript code. You can easily make 

class function hello(datastring : string) : string;

to give data to delphi and get some data back in you javascript.

If you want to push data from delphi to your webapp, use

crm.Browser.MainFrame.ExecuteJavaScript('alert(''JavaScript execute works!'');', 'about:blank', 0);

also in the guiclient example.
Message has been deleted

Pavel Rodriguez

unread,
Apr 6, 2013, 6:17:01 PM4/6/13
to delphichrom...@googlegroups.com
Also you culd just use a little old trick we used on flash years ago... you could set up OnJsAlert on your CEF and send the data from the webapp to delphi via a json object on a js alert. Then use some special string for detecting when its a regular js alert or your data alert. You could send your js alert from javascript in the following form:

alert('myJsAlertMessage:{type:"yourAction",data:"yourData"}'

on your OnJsAlert event in delphi you can check if the alert text has the "myJsAlertMessage" string and if it has the string  you can remove it an parse the json object and change the Result to true so the alert doesnt pop to the user, if it doesnt have the special string, means its a regular js alert from the website and you can let it pass.

Im suggesting using json but you can encode your string in any format you want for using the data, you could even use a comma separated format 

;)

Pavel Rodriguez

unread,
Apr 6, 2013, 6:18:33 PM4/6/13
to delphichrom...@googlegroups.com
i forgot, for sending data to your web app you can use the way mtjs said in his answer
;)

Ralph Wesseling

unread,
Apr 7, 2013, 10:35:56 PM4/7/13
to delphichrom...@googlegroups.com
Thanks I will lok into it.

At the moment I solved the issue by using a tinywebs server and just sending info to that app.

Rovlin Moodley

unread,
Sep 18, 2014, 8:49:55 AM9/18/14
to delphichrom...@googlegroups.com, prodri...@gmail.com
Hi Pavel

Do you have some sample code of the method that you mention below. I need to execute JS code in Delphi via DCEF component and I need to get a JSON object back. I then need to write a JSON parser to evaluate the data.

Thanks

Regards

Rovlin

Johan Hu

unread,
Sep 25, 2014, 11:55:49 AM9/25/14
to delphichrom...@googlegroups.com
Extension not always work.in some project it work but other.


在 2013年2月20日星期三UTC+8上午6时41分57秒,Ralph Wesseling写道:
Reply all
Reply to author
Forward
0 new messages