Results 1 to 6 of 6

Thread: Multiple webbrowser control parent/child pop up

  1. #1
    Lively Member
    Join Date
    Jul 10
    Posts
    93

    Multiple webbrowser control parent/child pop up

    I'm stuck here and could really use some help.

    I have webbrowser1 which has about 24 embedded links and the following html:

    HTML Code:
     launches child window pop up
            function launchFeatures(a, b, c, i, d, e, f, g)
            var m,u;
            var tn =  document.Detail.sub[i].value;
           if ( tn == null || tn == "" ) 
            url = "./feature.jsp?a=" + a + "&b=" + b + "&c=" + c + "&tn=" + tn + "&d=" + catg + "&action=" + act + "&f=" + f;
            MM_openBrWindow(u,'locked','scrollbars=1,resizable=1');     
            return true;
    If I call this function it creates a popup window. I'd prefer to have the pop up display in webbrowser2. I can do this using webbrowser2.navigate(url) but it doesn't preserve the link between the parent/child windows.

    The child window is therefore unable to make changes to the parent window. How can I accomplish this?

    Example code from the child window:

    HTML Code:
    window.opener.document.getElementById("feat" + value).value="* FEATURES"
    Last edited by jsublime; Jun 5th, 2012 at 02:23 PM.

  2. #2
    Frenzied Member
    Join Date
    Apr 09
    Location
    CA, USA
    Posts
    1,500

    Re: Multiple webbrowser control parent/child pop up

    Just to be sure, the node that you're trying to affect here:
    Code:
    window.opener.document.getElementById("feat" + value).value="* FEATURES"
    ...supports a "value" attribute, right? It's not a <div> or <p> or some other type of node?

  3. #3
    Lively Member
    Join Date
    Jul 10
    Posts
    93

    Re: Multiple webbrowser control parent/child pop up

    To be honest that might not be relevant, I'm not concerned about changing the label or caption of a button. Maybe this willl explain it a bit better...


    The child window has the following javascript function:

    HTML Code:
    window.opener.document.getElementById("featid" + value).value="* FEATURES";
    
     document.Feature.subidx.value = value;
      document.body.style.cursor = "wait";
      document.Feature.submit();


    As far was I can tell document.Feature.subidx.value = value; document.Feature.submit();
    gets submitted to the server and results in a Pending change which I can only finalize by submitting the parent form.



    For example:

    When I navigate these pages normally, I go to the child window and uncheck various boxes and apply, which calls the above functions. I then see a message which says "changes have been applied". At this point I can go back to the parent window and submit the changes.

    The problem I'm running into is that when I navigate like I detailed in the earlier post, I do no get the "changes have been applied" message and therefore cannot make changes.
    Last edited by jsublime; Jun 7th, 2012 at 03:52 PM.

  4. #4
    Frenzied Member
    Join Date
    Apr 09
    Location
    CA, USA
    Posts
    1,500

    Re: Multiple webbrowser control parent/child pop up

    I asked the previous question because it might've been the simplest explanation to your problem (if you were trying to alter the "value" attribute of an element that doesn't support it, it would fail).

    Otherwise, there doesn't seem to be enough code here to make a valid assessment; there is nothing inherently wrong with the snippets you've posted. If you'd like to post the full source (markup and script) of the parent and child pages, that'd be optimal.

  5. #5
    Lively Member
    Join Date
    Jul 10
    Posts
    93

    Re: Multiple webbrowser control parent/child pop up

    I wish I could share the code but I won't be able to...

    I've come to the realization theat I need to redirect the newwindow event.

    I've gotten pretty close by using an AxWebBrowser control instead of a regular webbrowser control... The problem I have now is that I'm having trouble access the DOM elements and I'm not able to find any documentation on the ax control.

    Does anyone have experience with this?

  6. #6
    Lively Member
    Join Date
    Jul 10
    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
  •