<strong>1. Block "JS error" pop-up window when opening a webpage </strong> method I: set WebBrowser's "Silent" property to "True" Method II: Code implementation m_web.put_silent (TRUE); //m_web is a Web control variable <strong>2. Masking other pop-up windows when opening a webpage </strong> method I: The method "Onambientproperty" associated with overloading the Web control's window is as follows://[description] This function is the main window method overload, You can block all scripts that open Web pages from running and pop-up windows, so use caution. #include "mshtmdid.h" BOOL cansdlg::onambientproperty (colecontrolsite* psite, DispID DispID, variant* pvar) {//TODO: Here Add private code and/or Call base class if (DispID = = Dispid_ambient_dlcontrol) {PVAR->VT = Vt_i4;pvar->lval = Dlctl_no_runactivexctls | dlctl_no_scripts | Dlctl_no_java | Dlctl_no_dlactivexctls | Dlctl_no_framedownload | dlctl_no_behaviors | Dlctl_no_framedownload | Dlctl_silent;return TRUE;} Return Cdialogex::onambientproperty (Psite, DispID, Pvar);} Method II: The "NEWWINDOW3" event related code for the overloaded Web control is as follows://This method prevents opening a Web page by blocking opening a new window to the popup void Cansdlg::newwindow3explorer1 (lpdispatch* ppdisp, bool* Cancel, unsigned long dwFlags, LPCTSTR Bstrurlcontext, LPCTSTR bstrurl) {//TODO: Add message processing hereOrder code//Do not open new window *cancel = TRUE;}
Screen WebBrowser Open the popup window of the webpage