Keywords: Webbrowser, webbrowser_v1, newwindow, newwindow2, newwindow3, inewwindowmanager
There are always two webbrowsers on your machine. One is webbrowser and the other is webbrowser_v1. Its classid is as follows:
Class_webbrowser: tguid = '{8856f961-340a-11d0-a96b-00c04fd705a2 }';
Class_webbrowser_v1: tguid = '{EAB22AC3-30C1-11CF-A7EB-0000C05BAE0B }';
The corresponding interfaces are iwebbrowser2 and iwebbrowser. Which one should we use?
According to Microsoft's recommendation, the former should be used as much as possible, because the latter is compatible with Internet Explorer 3. x. the corresponding iwebbrowser and iwebbrowserapp interfaces should also be discarded.
Due to the long history of Internet Explorer 3.x, webbrowser_v1 provides fewer events, but it is worth mentioning that the two events onnewwindow and onframebeforenavigate provided by webbrowser_v1 have almost the same parameters as onbeforenavigate:
onbeforenavigate (
bstr url,
long flags,
BSTR targetframename,
variant * postdata,
BSTR headers,
bool far * cancel)
onnewwindow (
bstr url,
long flags,
BSTR targetframename,
variant * postdata,
BSTR headers,
bool far * processed)
onframebeforenavigate (
bstr url,
long flags,
BSTR targetframename,
variant * postdata,
BSTR headers,
bool far * cancel)
Therefore, webbrowser_v1 makes it easy for our browser to capture its URL and related data when a new window is opened.ProcessedSetTrueTo cancel the pop-up of the new window. Similarly, frame processing is easier than webbrowser.
However, webbrowser_v1 does not support advanced interfaces, such as idochostuihandler. Even if we implement the idochostuihandler interface, it will not be called by webbrowser_v1. Therefore, if you want to implement advanced control such as XP interface themes and extended ie dom (Document Object Model) in your browser, you certainly cannot choose webbrowser_v1.
It is really troublesome to process the new window. I don't know why Microsoft removed the URL parameter from the onnewwindow2 event of the new version, in addition, the onnewwindow2 event cannot completely capture all new windows opened. However, if Windows XP SP2 is installed, the benefits will come back.
Windows XP SP2 upgrades Internet Explorer 6 and provides a new eventOnnewwindow3It occurs before the onnewwindow2 event. It also contains parameters such as the URL of the new window that can be filtered and processed.InewwindowmanagerInterface is the basis for implementing the function of filtering advertising windows in Windows XP SP2.
References:
Msdn: 185538 HOWTO: Cause navigation to occur in same webbrowser window
Reference address: Internet Explorer programming (1) webbrowser or webbrowser_v1