1 //1.显示网页
2 procedure TForm2.FormCreate(Sender: TObject);
3 begin
4 Panel1.Align := alTop;
5 CheckBox1.Anchors := [akTop, akRight];
6 Button1.Anchors := CheckBox1.Anchors;
7 CheckBox1.Caption := '编辑';
8 Button1.Caption := '显示网页文本';
9 WebBrowser1.Align := alClient;
10 WebBrowser1.Navigate('http://www.cnblogs.com/del/archive/2009/04/16/1437417.html');
11 end;
12
13 //2.编辑网页
14 procedure TForm2.CheckBox1Click(Sender: TObject);
15 begin
16 {这里是让整个页面可编辑, 也可以单独编辑某个元素}
17 WebBrowser1.OleObject.document.body.contentEditable := CheckBox1.Checked;
18 {有些浏览器需要这样设置: document.designMode = "On";}
19 end;
20
21 //3.显示网页文本
22 procedure TForm2.Button1Click(Sender: TObject);
23 begin
24 ShowMessage(WebBrowser1.OleObject.document.body.innerText);
25 end;