开发者

How can I get an IWebBrowser2 reference to the Internet Explorer window opened by clicking on a link?

Suppose I open a new Internet Explorer window by, for example, clicking a link with target="_blank" in the HTML link. Further suppose I'm doing so programmatically via COM. I realize I can attach to the DWebBrowserEvents2::NewWindow3 event, and be notified when a new window will be opened. How do I get a reference to that newly opened开发者_JS百科 window so I can manipulate it also?

Things to note:

  • I specifically do not want to cancel the NewWindow event and instantiate and return a new blank browser window in the ppDisp argument if I can help it.
  • I've thought about searching for each IE window (using FindWindow or some such), asking for its location, and comparing it to the bstrUrl argument, but I don't think that will work if the target has a redirection in it.
  • This is for an automated testing framework, so I am specifically driving Internet Explorer, not a hosted WebBrowser control.
  • I'm fully aware this will not find windows created by showModalDialog().
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜