在webbrown空间里编辑网页

  • A+
所属分类:[开发技巧]

程序功能:
通过修改 webbrown 实现对打开的网页 进行修改和编辑

程序效果如下:

代码文件:

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, OleCtrls, SHDocVw;

type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
Panel1: TPanel;
Button1: TButton;
CheckBox1: TCheckBox;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
Panel1.Align:= alTop;
CheckBox1.Anchors := [akTop,akRight];
Button1.Anchors := CheckBox1.Anchors;
CheckBox1.Caption := '编辑';
Button1.Caption := '显示网页文本';
WebBrowser1.Align := alClient;
WebBrowser1.Navigate('http://www.yrnote.com');
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(WebBrowser1.OleObject.document.body.innerText);
end;

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
WebBrowser1.OleObject.document.body.contentEditable := CheckBox1.Checked;

end;

end.


Demo下载:
200904171906203057.rar

  • 我的微信
  • 这是我的微信扫一扫
  • weinxin
  • 我的微信公众号
  • 我的微信公众号扫一扫
  • weinxin
广告也精彩
avatar
广告也精彩

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: