PRB: WebBrowser Control Disappears When Script Calls window.close() (253219)
The information in this article applies to:
- Microsoft Internet Explorer (Programming) 4.0
- Microsoft Internet Explorer (Programming) 4.01
- Microsoft Internet Explorer (Programming) 4.01 SP1
- Microsoft Internet Explorer (Programming) 4.01 SP2
- Microsoft Internet Explorer (Programming) 5
- Microsoft Internet Explorer (Programming) 5.01
- Microsoft Internet Explorer (Programming) 5.01 SP1
This article was previously published under Q253219 SYMPTOMS
When the script on a Web page calls the window.close property on itself, the WebBrowser control may disappear from the window. This article explains how to determine when this has occurred and how to take appropriate action.
RESOLUTION
In Internet Explorer 5.5, the WebBrowser control's default source interface, DWebBrowserEvents2, exposes a new event called WindowClosing. You can sink DWebBrowserEvents2 and set the Cancel parameter of the event to TRUE to prevent the close from occurring, or you can close the host windows.
In Internet Explorer 5.01 and earlier, the WM_PARENTNOTIFY message is sent to the parent of a child window when the child window is created or destroyed, or when the user clicks a mouse button while the cursor is over the child window. Thus, the hosting container of the WebBrowser control can watch for a WM_DESTROY notification message. If LOWORD of the wParam field of the WM_PARENTNOTIFY message is set to WM_DESTROY, the HIWORD of wParam contains the child window identifier, and the lParam field contains the hWnd of the child control. If the hWnd in lParam matches the hWnd of the WebBrowser control, you can determine that the WebBrowser control is being destroyed. You can then take the appropriate action, which typically means to close the child window for multiple-document interface (MDI) applications and quit the applications for single-document interface (SDI) applications.
REFERENCESFor more information about developing Web-based solutions for Microsoft Internet Explorer, visit the following Microsoft Web sites:
(c) Microsoft Corporation 2000, All Rights Reserved. Contributions by %2, Microsoft Corporation.
Modification Type: | Major | Last Reviewed: | 4/21/2006 |
---|
Keywords: | kbprb kbWebBrowser KB253219 kbAudDeveloper |
---|
|