I'm trying to scroll to the bottom of my displayed TWebBrowser document programmatically.
I've tried using the scroll method:
uses
MSHTML;
procedure TForm1.Button1Click(Sender: TObject);
var
Document: IHTMLDocument2;
begin
Document := WebBrowser.Document as IHTMLDocument2;
Document.parentWindow.scroll(0, Document.body.offsetHeight);
end;
I also tried using ScrollIntoView(false);:
procedure TForm1.Button1Click(Sender: TObject);
var
Document: IHTMLDocument2;
begin
Document := WebBrowser.Document as IHTMLDocument2;
Document.Body.ScrollIntoView(false);
end;
Just run
JavaScriptcode to scroll it:Or next generation,
TEdgeBrowsersupports directly scripts execution:Running JS code, allows scrolling easily to any element of the HTML document.
Using MS interfaces, without JS, it could be done like:
Be aware, MS interfaces works in legacy IE mode only, not supported by Edge engine.