|
-
May 22nd, 2012, 04:30 AM
#1
Thread Starter
New Member
Webbrowser popup Capture
hi all im in the middle of a little project using the webbrowser control in visual studio 2010 and im having a hell of a time trying to find out how to capture a popup,
i can navigate to a web page and enter details (login details) but when this information is passed to the website it pops up all the content of members area in a new ie window and not within the webbrowser control so i do not have any control over it can anyone help me get the popup to appear in the same webbrowser control or even a different one on the same form?
-
May 22nd, 2012, 06:50 AM
#2
Addicted Member
Re: Webbrowser popup Capture
Code:
Dim newurl as string
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
If Not Webbrowser1.Document Is Nothing Then
AddHandler WebBrowser1.Document.Click, AddressOf Web_DocClicked
End If
End Sub
Private Sub WebBrowser1_NewWindow(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles WebBrowser1.NewWindow
e.Cancel = True
If newurl <> "" then sender.Navigate(newurl)
End Sub
Public Sub Web_DocClicked(ByVal sender As Object, ByVal e As HtmlElementEventArgs)
Try
Dim elm As HtmlElement =Webbrowser1.Document.ActiveElement
If elm.OuterHtml.StartsWith("<A ") Then newurl = elm.GetAttribute("href")
Catch ex As Exception
MsgBox(ex)
End Try
End Sub
Last edited by edwinho; May 22nd, 2012 at 06:54 AM.
-
May 22nd, 2012, 09:10 AM
#3
Addicted Member
Re: Webbrowser popup Capture
Code:
Public Sub Web_DocClicked(ByVal sender As Object, ByVal e As HtmlElementEventArgs)
If WebBrowser1.StatusText <> "" then
Newurl=WebBrowser1.StatusText
end if
End Sub
You can also use the status text do do so!
Last edited by edwinho; May 22nd, 2012 at 09:13 AM.
-
May 23rd, 2012, 05:33 AM
#4
Thread Starter
New Member
Re: Webbrowser popup Capture
thanks for the help with this i have moved forward with it using your code but it seems to pick up the web address of the first page that loads up not the popup am i missing something? here is my code so far to capture the address
Dim newurl As String
Private Sub Wbvirgin_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WBVirginPopup.DocumentCompleted
If Not WBVirgin.Document Is Nothing Then
AddHandler WBVirgin.Document.Click, AddressOf Web_DocClicked
End If
End Sub
am i missing something?
Private Sub Wbvirgin_NewWindow(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles WBVirgin.NewWindow
' e.Cancel = True
If newurl <> "" Then sender.Navigate(newurl)
If WBVirgin.StatusText <> "" Then
newurl = Mid$(WBVirgin.StatusText, 12)
End If
WBVirginPopup.Navigate(newurl)
End Sub
'Public Sub Web_DocClicked(ByVal sender As Object, ByVal e As HtmlElementEventArgs)
' Try
' Dim elm As HtmlElement = WBVirgin.Document.ActiveElement
' If elm.OuterHtml.StartsWith("<A ") Then newurl = elm.GetAttribute("href")
' Catch ex As Exception
' MsgBox(ex)
' End Try
'End Sub
Public Sub Web_DocClicked(ByVal sender As Object, ByVal e As HtmlElementEventArgs)
If WBVirgin.StatusText <> "" Then
newurl = WBVirgin.StatusText
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|