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.

innerHtml

Post Reply
X11
Posts: 49
Joined: Thu Jul 25, 2019 10:15 am

innerHtml

Post by X11 »

Is there something similar to:

Code: Select all

  s := Chromium1.Browser.MainFrame.InnerHTML;
???
Thanx
User avatar
salvadordf
Posts: 4565
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: innerHtml

Post by salvadordf »

Hi,

The JSExtension demo has a context menu option called "Visit DOM in JavaScript" that gets the inner html in JavaScript and sends it to Delphi using an extension.
X11
Posts: 49
Joined: Thu Jul 25, 2019 10:15 am

Re: innerHtml

Post by X11 »

No. Without JavaScript.
X11
Posts: 49
Joined: Thu Jul 25, 2019 10:15 am

Re: innerHtml

Post by X11 »

ok, i copy/paste code from uJSExtension to uMiniBrowser:

Code: Select all

procedure TMiniBrowserFrm.Button2Click(Sender: TObject);
begin

      if (Chromium1.browser <> nil) and (Chromium1.browser.MainFrame <> nil) then
        Chromium1.browser.MainFrame.ExecuteJavaScript(
          'var testhtml = document.body.innerHTML;' +
          'myextension.sendresulttobrowser(testhtml, ' + quotedstr(CUSTOMNAME_MESSAGE_NAME) + ');',
          'about:blank', 0);

end;
and i get error
Debug Output:
[0824/164427.109:INFO:CONSOLE(1)] "Uncaught ReferenceError: myextension is not defined", source: about:blank (1)

Process MiniBrowser.exe (12208)
User avatar
salvadordf
Posts: 4565
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: innerHtml

Post by salvadordf »

Then search for the HTML element using the DOMVisitor functions and then call :

Code: Select all

MyNode.AsMarkup
Read these pages for more information about the CEF API with DOM nodes :
https://magpcss.org/ceforum/apidocs3/pr ... MNode.html
https://magpcss.org/ceforum/apidocs3/pr ... ument.html
User avatar
salvadordf
Posts: 4565
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: innerHtml

Post by salvadordf »

X11 wrote: Sat Aug 24, 2019 1:47 pm and i get error
Debug Output:
[0824/164427.109:INFO:CONSOLE(1)] "Uncaught ReferenceError: myextension is not defined", source: about:blank (1)

Process MiniBrowser.exe (12208)
Looks like the JavaScript extension wasn't registered before using it.
Post Reply