Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

how change html content?

Post Reply
darklaz
Posts: 2
Joined: Wed Dec 29, 2021 1:02 pm

how change html content?

Post 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
User avatar
salvadordf
Posts: 4620
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: how change html content?

Post 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.
darklaz
Posts: 2
Joined: Wed Dec 29, 2021 1:02 pm

Re: how change html content?

Post 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 ..
Post Reply