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 2: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>
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: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>
'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.




Reply With Quote