none
Getting access denied on HTMLDocument when using NewWindow3 RRS feed

  • Question

  • I have implemented NewWindow3 to provide my own tab or popup in a Forms.WebBrowser

    This works but I once navigated can't access the WebBrowser.Document, I get access denied

    I can access WebBrowser.ActiveXInstance.document but I have already written my code around Forms.HTMLDocument

    Private Sub NewWindow3(ByRef ppDisp As Object, ByRef Cancel As Boolean, ByVal dwFlags As NWMF, ByVal bstrUrlContext As String, ByVal bstrUrl As String)
    
    'Webframe is my class that contains a Forms.WebBrowser
    Dim Frm As New WebFrame
    
    Dim ShWeb As SHDocVw.WebBrowser = Frm.Web.ActiveXInstance
    ShWeb.RegisterAsBrowser = True
    ppDisp = ShWeb.Application
    
    Frm.FormBorderStyle = FormBorderStyle.SizableToolWindow
    Frm.Size = New Size(400, 400)
    Frm.Show()
    
    End Sub

    This is where I need to get HTML Document

    'This is my Forms.WebBrowser on the form
    Private Sub Web_Navigated(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles Web.Navigated
    Dim AXDoc = Web.ActiveXInstance.document 'OK
    Dim HTDoc = Web.Document 'access denied
    End Sub

    Any help would be appreciated


    Saturday, April 6, 2013 3:03 PM

Answers

All replies

  • The document is usually available after DocumentCompleted event, so try it instead of Navigated.

    Sunday, April 7, 2013 10:30 AM
  • Thanks Viorel_

    That seems to work, but it's a bit of a pain as I launch other threads during Browser_Navigated to get favicon and web certificate.

    It just means I'll have to recode to get the details from ActiveXInstance.document but where's the sense of that in Managed Code?

    Andrew

    Sunday, April 7, 2013 11:09 AM