Search code examples
c#internet-explorer-7interopwebbrowser-controlnew-window

access the newwindow inside the newwindow event


I use a webbrowser control in my application to get data from a specific web page. This web page won't work with the older IE because it specifically checks for the IE version. So I made a registry change that allows my application to work as IE 9 and everything is ok most of the time...

The problem is when a newwindow has to be opened. It won't display anything. I guess that the newwindow is acknowledged as IE 7 and I don't know how to make it disguise itself as IE9.

I also tried the other way round. I thought that if I intercepted the newwindow url then I could just send it to IE9 or open it in another instance of a webbrowser control. But the newwindow event only allows to cancel the event. You can't get any useful information out of it.

I believe that interop services is what I need but I know nothing about them.

So I've got two questions:
(1) Can I make the newwindow identify as IE9? (and how...)
(2) How can I get the newwindow url using interop services (or anything, I wouldn't care)?


Solution

  • It is quite strange (from my perspective) that the WebBrowser control doesn't surface the much-more-useful NewWindow3 event.

    This CodeProject article describes a remarkably simple way to make it available.