0

I want to use the MSHTML interfaces IHTMLDocument2, IHTMLElement2, IHTMLElementCollection, etc with TWebBrowser.

In Document := WebBrowser.Document as IHTMLDocument2; when TWebbrowser.SelectedEngine = IEOnly then everything is fine.

But, when I changed the property TWebBrowser.SelectedEngine = EdgeOnly or EdgeIfAvailable then WebBrowser.Document is nil.

How can I fix this?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Ahmet
  • 1
  • 1
    As far as I know, Edge do not expose IHTMLDocument2 interface. If you want to access the html document, you have to inject javascript code using EdgeBrowser1.ExecuteScript method. – fpiette Nov 21 '22 at 10:31
  • I have a live application built with delphi version 10.2. and this application is using TWebBrowser component. However, Internet Explorer started having problems with some websites. When I researched these problems, I saw that new features were added to the TWebBrowser component with the delphi 10.4 version. For example (SelectedEngine). I was hoping to fix these issues with as few changes as possible to my app. Using the javascript method is quite costly for me – Ahmet Nov 21 '22 at 11:22
  • AFAIK for Edge there is `TEdgeBrowser` https://docwiki.embarcadero.com/RADStudio/Sydney/en/Using_TEdgeBrowser_Component_and_Changes_to_the_TWebBrowser_Component – Dalija Prasnikar Nov 21 '22 at 13:03
  • @DalijaPrasnikar I can't use IHTMLDocument2 for TEdgeBrowser also. – Ahmet Nov 21 '22 at 13:11
  • I know, the documentation link states all the differences. Since `TEdgeBrowser` does not have Document property it is not unexpected that `TWebBrowser` using Edge does not have it either. This is not a solution for you but just gives another insight into your problem. – Dalija Prasnikar Nov 21 '22 at 13:28
  • 1
    TWebBrowser with Edge selected is the same as TEdgeBrowser component. In both cases, under the wood it is Microsoft Edge which actually use Google Chrome engine with is TOTALLY different than Internet Explorer as far as API is concerned. You have to use JavaScript. Sorry. – fpiette Nov 21 '22 at 17:45

0 Answers0