How to control the webbrowser pop-up window in VB: Because I never use webbrowser or do not do browser. I am not very familiar with it. I have found several articles and hope to help you! Method 1: The Method to Control webbrowser not to bring up the IE window is to add the following code in the newwindow2 event of the control: Set ppdisp = webbrowsertemp. Object 'webbrowsertemp is another webbrowser control added in the form. If the pop-up window is disabled, add the following code to the newwindow2 event: Cancel = true From: http://lang.lctu.cn/article.asp? Id = 86 Method 2: Use ondownloadbegin and ondownloadcomplete Take chtmlview as an example. The pop-up ad window is opened through chtmlview: onnewwindow2 (lpdispatch * ppdisp, bool * cancel. I don't want to talk about onnewwindow2. I just want to talk about the 2nd parameter bool * cancel. When cancel is set to false, a new window cannot be opened. If the value of this parameter in your chtmlview is always set to false, all pop-up windows cannot be opened, and the advertisement window will naturally disappear. ~~~ If it is always false, isn't it possible to browse a normal webpage? Don't be busy. Next, let's make this parameter return false when appropriate. Aside from CHtmlView, let's look back at the pop-up advertisement window for IE download webpage: OnDownloadBegin ----> found Js or vbs such as window. open ----> OnNewWindow2 ----> OnDownloadComplete After learning about the above process... when can I set the 2nd parameter of OnNewWindow2 to FALSE! The following is my practice. Add a member variable BOOL m_bPop to your CNoPopHtmlView derived from CHtmlView; Initialize m_bPop to m_bPop = TRUE in the constructor; Overload the OnDownloadBegin virtual function, and add m_bPop = FALSE; Overload the OnDownloadComplete virtual function, and add m_bPop = TRUE; Reload the OnNewWindow2 virtual function and add the following to it: Cancel = m_bPop; In this way, CNoPopHtmlView will not open the advertisement window. The key is to understand the download and pop-up windows of IE. (The method in this article is also applicable to CWebBrowser2, whether you use VC or Delphi, the key is to understand the IE download and pop-up window process) The above is to filter the advertisement window in the self-developed browser. In fact, you can use BHO (Browser Helper Object) to write an advertisement window filter for IE. In BHO, you can use IObjectWithSiteImpl: SetSite to obtain the IWebBrowser2 pointer, and then use Invoke to process OnDownloadBegin/OnDownloadComplete/OnNewWindow2 and other events. The mode is the same as above. From: http://dev.csdn.net/develop/article/10/10691.shtm Method 3: Set the silent attribute to True. From: http://www.wenyiwen.cn/a20/how121021.htm I have not obtained a specific ticket. Can I see if it is applicable? |