Delphi - 如何在当前的 TWebBrowser 上制作 TEdit 标签 url
Delphi - How to make a TEdit label the TWebBrowser curently url
我正在创建一个网络浏览器,当我打开带有 link 的网页时,我使用 TWebBrowser 和 TEdit 输入 url.But 然后当我单击 link, 我转到另一个网页,我的问题是如何使 TEdit 标签成为当前 url.
为 OnNavigateComplete2
事件编写处理程序:
procedure TForm1.WebBrowser1NavigateComplete2(ASender: TObject;
const pDisp: IDispatch; const URL: OleVariant);
begin
Edit1.Text := URL;
end;
Write an OnNavigateComplete2 event handler to take specific action
when the Web browser successfully navigates to a new resource. The
event can occur before the document is fully downloaded, but when it
occurs at least part of the document must be received and a viewer for
the document created.
Note: Unlike the OnDownloadComplete event, OnNavigateComplete2 does not occur if the operation is not successful.
一个不存在 URL 的测试表明它无论如何都会触发。
您可能还想考虑为 OnBeforeNavigate2
事件编写一个处理程序,以备不时之需 f.ex。以编程方式取消导航到 URL
procedure TForm1.WebBrowser1BeforeNavigate2(ASender: TObject;
const pDisp: IDispatch; const URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
begin
Edit1.Text := URL;
end;
我正在创建一个网络浏览器,当我打开带有 link 的网页时,我使用 TWebBrowser 和 TEdit 输入 url.But 然后当我单击 link, 我转到另一个网页,我的问题是如何使 TEdit 标签成为当前 url.
为 OnNavigateComplete2
事件编写处理程序:
procedure TForm1.WebBrowser1NavigateComplete2(ASender: TObject;
const pDisp: IDispatch; const URL: OleVariant);
begin
Edit1.Text := URL;
end;
Write an OnNavigateComplete2 event handler to take specific action when the Web browser successfully navigates to a new resource. The event can occur before the document is fully downloaded, but when it occurs at least part of the document must be received and a viewer for the document created.
Note: Unlike the OnDownloadComplete event, OnNavigateComplete2 does not occur if the operation is not successful.
一个不存在 URL 的测试表明它无论如何都会触发。
您可能还想考虑为 OnBeforeNavigate2
事件编写一个处理程序,以备不时之需 f.ex。以编程方式取消导航到 URL
procedure TForm1.WebBrowser1BeforeNavigate2(ASender: TObject;
const pDisp: IDispatch; const URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
begin
Edit1.Text := URL;
end;