Page 1 of 1

innerHtml

Posted: Sat Aug 24, 2019 1:19 pm
by X11
Is there something similar to:

Code: Select all

  s := Chromium1.Browser.MainFrame.InnerHTML;
???
Thanx

Re: innerHtml

Posted: Sat Aug 24, 2019 1:36 pm
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.

Re: innerHtml

Posted: Sat Aug 24, 2019 1:42 pm
by X11
No. Without JavaScript.

Re: innerHtml

Posted: Sat Aug 24, 2019 1:47 pm
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)

Re: innerHtml

Posted: Sat Aug 24, 2019 1:48 pm
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

Re: innerHtml

Posted: Sat Aug 24, 2019 1:49 pm
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.