且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

禁用在Web浏览器控件中加载图片

更新时间:2022-02-13 22:07:45

我看了一下代码,您还没有声明RegExg对象.

您需要一个import语句,以及一个RegEx对象;请参见下面的代码;

I had a look at the code, and you have not declared the RegExg object.

You need an import statement, and also a RegEx object; see the code below;

Imports System.Text.RegularExpressions
Public Class Form1
Private Sub ButtonGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGo.Click
        'Navigate to Address
        WebBrowser1.Navigate(TextBoxAddress.Text)
End Sub
Private Sub ButtonKillImages_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonKillImages.Click
    'Source String
    Dim origHTML As String
    origHTML = WebBrowser1.DocumentText
    'New String for Ouput
    Dim newHTML As String
    'The Regular Expression Object
    Dim regx As New Regex("<img.*/>")
    'Perform the RegEx action
    newHTML = regx.Replace(origHTML, "")
    'Load back into browser the new string
    WebBrowser1.DocumentText = newHTML
End Sub
End Class


但已加载!
只是禁用显示未加载!
But it is alredy loaded!
Just disabled displaying not loading!