TWebBrowser - 阻止新的 windows

TWebBrowser - prevent new windows

我有一个 TWebBrowser 打开网站,我想阻止它在我点击链接时创建新的 windows。

我更喜欢在包含浏览器的同一个 window 中显示新的 URL。 有什么办法吗?

如果您正在使用具有 Cancel 参数的 VCL TWebBrowser component, it has an OnNewWindow2 事件:

Cancel allows the event handler to block the creation of a new window. When the event handler sets Cancel to true, the Web browser tries to display the target resource in its current window, starting with an OnBeforeNavigate2 event.