Page 1 of 1

how change html content?

Posted: Wed Dec 29, 2021 1:19 pm
by darklaz
Hello, first of all thank you for this useful component.
I was using TWebBrowser in my project and I could reach an element on the page with its Id and change its content (GetElementbyId).

How can I do this with WebView4Delphi?

Thanks

Re: how change html content?

Posted: Wed Dec 29, 2021 2:24 pm
by salvadordf
Hi,

As far as I know, WebView2 doesn't expose any API method to access the DOM directly.

However, you can execute some custom JavaScript code that searches for that element and sends the information you need to the Delphi application with a message.

See the BrowserHostAppCommunication demo for all the details about sending messages between the browser and Delphi.

Re: how change html content?

Posted: Thu Dec 30, 2021 11:14 am
by darklaz
salvadordf wrote: Wed Dec 29, 2021 2:24 pm Hi,

As far as I know, WebView2 doesn't expose any API method to access the DOM directly.

However, you can execute some custom JavaScript code that searches for that element and sends the information you need to the Delphi application with a message.

See the BrowserHostAppCommunication demo for all the details about sending messages between the browser and Delphi.
Thanks for reply, i do it with your suggestion ..