IWebBrowser2: how to force links to open in new window?

前端 未结 5 1146
醉梦人生
醉梦人生 2020-12-11 06:20

The MSDN documentation on WebBrowser Customization explains how to prevent new windows from being opened and how to cancel navigation. In my case, my application is hosting

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-11 07:04

    I'm hypothesising here but yet another approach could be to maintain a count of navigation events, incrementing the counter on DISPID_BEFORENAVIGATE2 and decrementing it on occurrences of DISPID_NAVIGATECOMPLETE2 and DISPID_NAVIGATEERROR. With that in place, you could speculate that whenever you get DISPID_BEFORENAVIGATE2 and your counter is at zero, it is actual user navigation / link invocation.

    I have no idea whether this approach would work, or whether those are the right events you'd need to make it work, but it could be worth investigating.

提交回复
热议问题