Results 1 to 6 of 6

Thread: Multiple webbrowser control parent/child pop up

Threaded View

  1. #6

    Thread Starter
    Lively Member
    Join Date
    Jul 2010
    Posts
    93

    Re: Multiple webbrowser control parent/child pop up

    I know it's confusing to understand what I'm trying to do without source code so I rebuilt it in a simple way.


    Webbrowser1 loads html1.htm at startup. I have a handler which cancels the popup and redirects webbrowser2 to the pop up url (I simplified this a bit in this demo by hardcoding html2).

    Code:
       Private Sub WebBrowser1_NewWindow(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles WebBrowser1.NewWindow
    
            ' This will be triggered only when link tries to open in new window.
            ' That means active element in web document will always be a Link.
    Dim myElement As HtmlElement = WebBrowser1.Document.ActiveElement
            Dim target As String = myElement.GetAttribute("Url")
           
    'target *should* capture the destination url which is yahoo.com in this case. in this example i am redirecting the page to a hardcoded page
    
            WebBrowser2.Navigate(HTML2.html)
    
            'cancel opening IE window
            e.Cancel = True
    
    
        End Sub




    HTML 1:
    HTML Code:
    <SCRIPT type = "text/Jscript">
         function openWin()
         {
              var win;
              win = window.open("http://www.yahoo.com");
         }
    </SCRIPT>
    </HEAD>
    <BODY>
    
    <button onClick="openWin()">Open New Window</button>
    
    </BODY>
    </HTML>
    HTML 2:


    HTML Code:
    <SCRIPT type = "text/Jscript">
         function openWin()
         {
              var win;
              win = window.opener.navigate("http://www.google.com");
         }
    </SCRIPT>
    </HEAD>
    <BODY>
    
    <button onClick="openWin()">Open New Window</button>
    
    </BODY>
    </HTML>
    After I click the link in wb1, wb2 has a function called window.opener which tells the parent window (wb1) to navigate to google.com. I get the following error:

    'window.opener' is null or not an object.

    Basically webbrowser2 doesn't have any connection to it's parent window and I can't seem to set it programtically.
    Last edited by jsublime; Jun 15th, 2012 at 09:45 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width