TWebBrowser 与 MSHTML(2): 获取 window 对象的时机 这是在页面下载完毕后即刻获取:unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, OleCtrls, SHDoc...
TWebBrowser 与 MSHTML(2): 获取 window 对象的时机
这是在页面下载完毕后即刻获取:
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, OleCtrls, SHDocVw, StdCtrls; type TForm1 = class(TForm) WebBrowser1: TWebBrowser; Button1: TButton; Button2: TButton; procedure FormCreate(Sender: TObject); procedure WebBrowser1DocumentComplete(ASender: TObject; const pDisp: IDispatch; var URL: OleVariant); end; var Form1: TForm1; implementation {$R *.dfm} uses MSHTML; var window: IHTMLWindow2; {建立时同时打开页面} procedure TForm1.FormCreate(Sender: TObject); begin WebBrowser1.Align := alTop; WebBrowser1.Navigate('http://del.cnblogs.com'); end; {当页面打开完毕时获取 window 对象} procedure TForm1.WebBrowser1DocumentComplete(ASender: TObject; const pDisp: IDispatch; var URL: OleVariant); begin if pDisp = (ASender as TWebBrowser).Application then begin window := ((ASender as TWebBrowser).Document as IHTMLDocument2).parentWindow; end; end; end. posted on 2009-03-13 17:20? 万一? 阅读(4466)? 评论(7)? 编辑? 收藏
沃梦达教程
本文标题为:TWebBrowser 与 MSHTML(2): 获取 window 对象的时机
基础教程推荐
猜你喜欢
- Ajax发送和接收二进制字节流数据的方法 2022-12-28
- Uncaught TypeError: Cannot read properties of undefined (reading ‘install‘)报错 2022-11-02
- Vue入门笔记Day 8 2023-10-08
- 探讨Ajax中有关readyState(状态值)和status(状态码)的问题 2023-01-20
- JSscript标签有哪些属性 2023-08-08
- HTML5表单及其验证 2023-10-27
- vue条形码,二维码,打印总结分享 2023-10-08
- JavaScript中常见的事件用法小结 2023-07-10
- javascript – 是否可以从内存中的html字符串加载电子webContents? 2023-10-25
- 用ajax传递json到前台中文出现问号乱码问题的解决办法 2023-01-26