当前位置:编程文档 >> DELPHI >> delphi中对ihtmldocument2的使用教程
首页

delphi中对ihtmldocument2的使用教程

所属类别:DELPHI
推荐指数:★★☆
文档人气:19
本周人气:8
发布日期:2008-8-15

一:读取某网页内容

程序单元部分加入mshtml

读取的时候,webbrowser控件得要完整的打开某一网页,程序代码如下

在创建窗体的时候打开一网页

webbrowser1.navigate('http://www.programbbs.com')

procedure TForm1.Button1Click(Sender: TObject);

begin

memo1.lines.add(ihtmldocument2(webbrowser1.document).body.outerhtml);

end;

这样一来memo1中显示www.programbbs.com源码

二:利用webbrowser1控件浏览某txt中文件的内容,并以html形式来显示出来

在webbrowser1的控件中的ondocumentcomplete事件加入如下代码

procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;

const pDisp: IDispatch; var URL: OleVariant);

var

webdoc:htmldocument ;

webbody:htmlbody;

begin

webdoc:=webbrowser1.document as htmldocument;

webbody:=webdoc.body as htmlbody;

webbody.insertAdjacentHTML('beforeend','<form method="POST" action="">');

webbody.insertAdjacentHTML('beforeend','Password: ');

webbody.insertAdjacentHTML('beforeend','<input type="password" >');

webbody.insertAdjacentHTML('beforeend','<input type="submit" value="LOGIN" >');

webbody.insertAdjacentHTML('beforeend',' ');

webbody.insertAdjacentHTML('beforeend','</form>');

end;
 

文档说明:

     

相关文档


读取评论列表……