这是在页面下载完毕后即刻获取:
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.
以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索页面
, webbrowser
, window
, end
, webbrowser1
, #mshtml
, mshtml
procedure
,以便于您获取更多的相关知识。
时间: 2024-11-08 20:20:36