How can I read hyperlinks while the page is loading in WebView2 VB.NET

Apostolos Doudakmanis 41 Reputation points
2022-06-15T17:17:26.347+00:00

I am building a tabbed browser with WebView2

How can I read the hyperlinks in StatusText while the page is loading in WebView2 so I can tell if they are hyperlinks, videos, photos and programs?

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,579 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Apostolos Doudakmanis 41 Reputation points
    2022-06-18T10:03:01.277+00:00

    from this image that appears the arrow shows the address it loads ...
    212657-webview2.png

    and in NavigateStarting I want to check this address so I can edit it

    Private Sub brws_NavigationStarting(sender As Object, e As CoreWebView2NavigationStartingEventArgs) Handles brws.NavigationStarting  
          
        TabControl1.SelectTab(TabControl1.TabCount - 1)  
    
        StatusText.Text = "Loading ... " & e.Uri.ToString  
    
        If PressedStopButton = True Then  
            e.Cancel = True  
            StatusText.Text = "Cancel loading ... "  
            PressedStopButton = False  
            Exit Sub  
        End If  
    
       If InStr(1, e.Uri.ToString, "ads", vbTextCompare) Then  
            Cancel = True  
        Else  
            Cancel = False  
        End If  
    
    End Sub  
    

    Also when I move the mouse over a post title or image it shows me the address in StatusText

    0 comments No comments

  2. Jiachen Li-MSFT 26,671 Reputation points Microsoft Vendor
    2022-06-20T02:40:23.67+00:00

    Hi @Apostolos Doudakmanis ,
    Please check the following documentations to see if they are helpful to you.
    CoreWebView2.StatusBarText Property
    CoreWebView2.StatusBarTextChanged Event
    Best Regards.
    Jiachen Li

    ----------

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  3. Castorix31 81,741 Reputation points
    2022-06-22T16:54:46.317+00:00

    I only get StatusBar text when I move the mouse on links/images/...

    Parts of code (cannot post here...) : WebView21_StatusBarTextChanged