This is a question from the Forum. The sample code is as follows, mainly to understand the Document Object.
// ------ This forum does not support Delphi code styles
Unit unit1;
Interface
Uses
Windows, messages, sysutils, variants, classes, graphics, controls, forms,
Dialogs, olectrls, shdocvw, stdctrls, mshtml;
Type
Tform1 = Class (tform)
Webbrowser1: twebbrowser;
Button1: tbutton;
Memo1: tmemo;
Procedure formcreate (Sender: tobject );
Procedure button1click (Sender: tobject );
Private
{Private Declarations}
Public
{Public declarations}
End;
VaR
Form1: tform1;
Implementation
{$ R *. DFM}
Procedure tform1.formcreate (Sender: tobject );
Begin
Webbrowser1.navigate ('www .csdn.net ');
End;
Procedure tform1.button1click (Sender: tobject );
VaR DOC: mshtml. ihtmldocument2;
VaR select: mshtml. ihtmltxtrange;
Begin
DOC: = self. webbrowser1.document as mshtml. ihtmldocument2;
Select: = Doc. selection. createRange () as mshtml. ihtmltxtrange;
Memo1.text: = select.html text;
End;
End.