TWebBrowser访问IFrame
来源:互联网 发布:c语言hello world程序 编辑:程序博客网 时间:2024/06/05 07:25
//网上资料只提到获取Frames的内容,IFrame就没有提及到了。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, SHDocVw, MSHTML;
type
TForm1 = class(TForm)
WebBrowser: TWebBrowser;
Button: TButton;
mmo1: TMemo;
procedure ButtonClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ButtonClick(Sender: TObject);
var
Tabi:Integer;
doc:IHTMLDocument2;
Collection:IHTMLElementCollection;
Element:IHTMLElement;
frames:IDispatch;
framew:IHTMLWindow2;
i:OleVariant;
s:string;
ii,divi:Integer;
input:IHTMLInputElement;
docii:HTMLDocument;
iframe:IWebBrowser;
begin
doc:=Webbrowser.document as IHTMLDocument2;
i:=4;
frames:=doc.frames.item(i);
framew:=frames as IHTMLWindow2;
docii:=framew.document as HTMLDocument;
collection:=docii.all.tags('iframe') as IHTMLElementCollection;
//ShowMessage(IntToStr(Collection.length));
for ii:= 0 to collection.length -1 do
begin
iframe:= Collection.item(ii,varEmpty) as IWebBrowser; //在网上查过不少文章,最后自己尝试成功,关键就是这里。
doc:=iframe.document as IHTMLDocument2;
Element:=doc.body as IHTMLElement;
Element.innerHTML:=mmo1.Text;
end;
//总结:获取Webbrowser的iframe的内容,需要把iframe元索强制转换为iwebbrowser接口,
//之后,还要强制转换为ihtmlelement接口才可以成功访问iframe里面的元素,否则程序运行出错;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
WebBrowser.Navigate('http://******************');
end;
end.
//@_@ 英文不好,变量名都是乱取的。。。。。编程基础也不是很牢固,路过的朋友请不要笑。。。。
- TWebBrowser访问IFrame
- Asp.net访问Iframe
- 网页iframe访问
- iframe跨域javascript访问
- iframe跨域访问
- iframe 跨协议访问
- easyui跨iframe访问
- iframe跨域访问
- iframe跨域访问
- iframe跨域访问
- iframe跨域访问
- iframe跨域访问
- iframe跨域访问
- Iframe跨域访问
- iframe父级与iframe子级间访问
- iframe表单跨域访问
- iframe跨域访问问题
- python访问iframe内节点
- 解决Visual C++ 2008 Feature Pack Release安装失败的方法 —— 在VS2008简体中文版上安装TR1
- php 删除指定文件
- 二叉排序树专题
- Ext.ux.form.SearchField使用方法
- C语言中的多线程编程
- TWebBrowser访问IFrame
- 数据结构 - 返回单链表的中间结点
- 新华社-中国移动联手打造盘古搜索 2月22日上线
- Oracle中的数据字典技术简析
- 层内文字超出显示省略号[转]
- ICML的出版社问题
- c++中所有关键字的解释
- Web开发人员必备的20款超赞的jQuery插件
- log4net 关于配置文件的问题