webbroser close page

I

ilario santamaria

hello

loading a page in webbroser, try a link and click, you open the pagita everything ok



Private Sub caricapagina(ByVal nomesito As String)
Try
WebBrowser1.Navigate(New Uri(nomesito))

With WebBrowser1
Do While .ReadyState <> WebBrowserReadyState.Complete
Application.DoEvents()
Loop

CercanelSito (WebBrowser1,"nome", "titlesito" )


End With

Catch ex As System.UriFormatException
Return
End Try

End Sub



Private sub CercanelSito(ByVal WebBrowserName As WebBrowser, byval NameSito as string, byval titlesito as string)


Dim i As Integer = 0

For Each Link As HtmlElement In WebBrowserName.Document.Links

If Link.OuterHtml.Contains(NameSito) = True Then
WebBrowserName.Document.Links(i).InvokeMember("Click")
Exit For

End If
i += 1
Next


''''''' ok open new page

'''''' problem no close


'close page '''''''

Dim isDocumentOpened As Boolean = True

Do While isDocumentOpened


System.Threading.Thread.Sleep(1000)


Dim procs As System.Diagnostics.Process() = System.Diagnostics.Process.GetProcessesByName("IEXPLORE")

isDocumentOpened = False
For Each proc As System.Diagnostics.Process In procs
isDocumentOpened = proc.MainWindowTitle.Contains("titlesito")

If isDocumentOpened Then
proc.Kill()
Exit For

End If

Next

Loop

End Sub

the problem can not close new page explorer

if writing code in a button does everything


Dim procs As System.Diagnostics.Process() = System.Diagnostics.Process.GetProcessesByName("IEXPLORE")

For Each proc As System.Diagnostics.Process In procs

if proc.MainWindowTitle.Contains("titlesito") = true then

proc.Kill()
Exit For

End If

Next


thanks
ilario
 
K

kimiraikkonen

hello

loading a page in webbroser, try a link and click, you open the pagita everything ok

    Private Sub caricapagina(ByVal nomesito As String)
        Try
            WebBrowser1.Navigate(New Uri(nomesito))

            With WebBrowser1
                Do While .ReadyState <> WebBrowserReadyState.Complete
                    Application.DoEvents()
                Loop

                CercanelSito (WebBrowser1,"nome", "titlesito" )

            End With

        Catch ex As System.UriFormatException
            Return
        End Try

    End Sub

    Private sub CercanelSito(ByVal WebBrowserName As WebBrowser, byval NameSito as string, byval titlesito as string)

        Dim i As Integer = 0

        For Each Link As HtmlElement In WebBrowserName.Document.Links

            If Link.OuterHtml.Contains(NameSito) = True Then
                WebBrowserName.Document.Links(i).InvokeMember("Click")
                Exit For

            End If
            i += 1
        Next

'''''''   ok open new page

''''''  problem no close

     'close page '''''''

        Dim isDocumentOpened As Boolean = True

        Do While isDocumentOpened

            System.Threading.Thread.Sleep(1000)

            Dim procs As System.Diagnostics.Process() = System.Diagnostics.Process.GetProcessesByName("IEXPLORE")

            isDocumentOpened = False
            For Each proc As System.Diagnostics.Process In procs
                isDocumentOpened = proc.MainWindowTitle..Contains("titlesito")

                If isDocumentOpened Then
                    proc.Kill()
                    Exit For

                End If

            Next

        Loop

     End Sub

the problem can not close new page explorer

if writing code in a button does everything

Dim procs As System.Diagnostics.Process() = System.Diagnostics.Process.GetProcessesByName("IEXPLORE")

                        For Each proc As System.Diagnostics.Process In procs

 if proc.MainWindowTitle.Contains("titlesito") = true then

                                   proc.Kill()
                    Exit For

                End If

            Next

thanks
ilario

You want to kill IE?:

Try this:

Imports System.Diagnostics
Imports System.Diagnostics.Process

For each p As Process In Process.GetProcessesByName("iexplore")

p.Kill

Next

HTH,

Onur Güzel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top