FIX: MsgBox "Permission Denied" Error in WebBrowser Control

Last reviewed: March 5, 1998
Article ID: Q182032
The information in this article applies to:
  • Microsoft Visual Basic, Scripting Edition, versions 1.0, 1.1, 2.0
  • Microsoft Internet Explorer (Programming), versions 3.0, 3.01, 3.02
  • The Microsoft Foundation Classes (MFC) included with:

        - Microsoft Visual C++, 32-bit Editions, versions 4.2b, 5.0
    

SYMPTOMS

When navigating to a page in an application that hosts the Microsoft WebBrowser control, you will get the following scripting error message:

   Permission Denied

This error occurs specifically at a location in script code where the VBScript method MsgBox is called.

It also occurs if the WebBrowser control is being hosted using Visual C++ and the Microsoft Foundation Classes' (MFC) default control containment support.

CAUSE

This error occurs because the IOleInPlaceFrame implementation of the control container is not returning S_OK from the EnableModeless method.

MFC's control containment support returns E_NOTIMPL, which causes the scripting engine to not allow a message box to be displayed; hence, the "Permission Denied" error.

RESOLUTION

Modify the control container to return S_OK from the IOleInPlaceFrame::EnableModeless method. EnableModeless should prepare the top-level frame for the display or removal of a modal dialog box based on the supplied Boolean parameter. Refer to the documentation for IOleInPlaceFrame::EnableModeless for more information on how to implement this method.

This problem does not occur when hosting the Internet Explorer 4.0 WebBrowser control in an MFC application.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug has been corrected in Microsoft Internet Explorer 4.0.

MORE INFORMATION

MFC containers can use a call to CWinApp::EnableModeless to fully implement this function and return S_OK. Here is a code sample:

   STDMETHODIMP CMyOleControlContainer::XMyOleIPFrame::EnableModeless(BOOL
     f)
   {
      METHOD_PROLOGUE_EX(CMyOleControlContainer, OleIPFrame)

      CWinApp* pApp = AfxGetApp();
      if ( ! pApp )
         return E_FAIL;

      pApp->EnableModeless( f );
      return S_OK;
   }

REFERENCES

For additional information on modifying MFC control containment support to override this method, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q141277
   TITLE     : How to Override an Interface in an MFC Application

Keywords          : AXSDKSripting kberrmsg
Technology        : kbInetDev
Version           : WINDOWS:1.0,1.1,2.0,3.0,3.01,3.02; WINNT:4.2b,5.0
Platform          : WINDOWS winnt
Issue type        : kbbug
Solution Type     : kbfix


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: March 5, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.