也在 TWebBrowser 中打开新页面

发布于 2024-11-24 04:25:09 字数 337 浏览 2 评论 0原文

我创建了一个带有 twebBrowser 的应用程序。问题是,当我单击某个链接(例如 gmail)时,它会在我的默认浏览器(即 IE)的新窗口中打开。我如何让它像 firefox 或 chrome 等一样工作,在它们的窗口中打开单击的链接。该 URL 应在 TWebBrowser 的窗口中打开。我必须在运行时创建一个新的表单并在运行时使用 TWebBrowser 吗?不需要这样的代码,想法就可以了,

提前致谢。

PS 我的组织阻止 Gmail、Facebook 等,但是通过我的 TWebBrowser,我可以打开它们。我的 QA 人员可以在他们的日志中看到这一点吗?我的猜测是否定的,因为那时他们会阻止它。您对此有何评论

I have created an app with a twebBrowser in it. Problem is when i click on some link, in say gmail, it opens in a new window of my default browser( which is IE). how do i make it work like firefox or chrome etc. which opens the clicked links in their windows. The url's should open in the TWebBrowser's window. Must i create a new Form at runtime with TWebBrowser in it at runtime for that? Code not needed as such, ideas will do

Thanks in Advance.

P.S. My org blocks Gmail, Facebook etc. , However through my TWebBrowser, i can open them. Can my QA ppl see that in their log? My guess will be no, since then they would block it. What is your comment on this

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

相权↑美人 2024-12-01 04:25:09

TWebBrowser 有一个 OnNewWindow2 事件。假设持有 TWebBrowser 的表单名为 Form1 并且 Web 控件本身名为 WebBrowser1,请编写如下处理程序:

procedure TForm1.WebBrowser1NewWindow2(ASender: TObject; var ppDisp: IDispatch; var Cancel: WordBool);
var NF: TForm1;
begin
  NF := TForm1.Create(Application);
  NF.Visible := True;
  NF.WebBrowser1.RegisterAsBrowser;
  ppDisp := NF.WebBrowser1.DefaultInterface;
end;

这将创建一个新窗口,当“单击”应该打开一个新窗口时,带有一个新的 TWebBrowser

TWebBrowser has an OnNewWindow2 event. Assuming the form holding the TWebBrowser is named Form1 and the web-control itself is named WebBrowser1, write a handler like this:

procedure TForm1.WebBrowser1NewWindow2(ASender: TObject; var ppDisp: IDispatch; var Cancel: WordBool);
var NF: TForm1;
begin
  NF := TForm1.Create(Application);
  NF.Visible := True;
  NF.WebBrowser1.RegisterAsBrowser;
  ppDisp := NF.WebBrowser1.DefaultInterface;
end;

This will create a new window, with a new TWebBrowser when the "click" is supposed to lead to a new window.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文