禁用在Web浏览器控件中加载图片 [英] Disable loading pictures in webbrowser control

查看:179
本文介绍了禁用在Web浏览器控件中加载图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI
我有一个在互联网上找到的代码.它是为vb 2003制作的:
显然,它禁用了页面上的图片,在查看代码后听起来很合理.但是正如我所说,它是为vb 2003设计的,我无法在vb.net中使用它.

HI
I have a code that i found on the internet. it is made for vb 2003:
Apparently it disables the pictures on a page, which sounds fair after looking to the code. But as i said, its made for vb 2003 and i can''t get it to work in vb.net.

Dim origHTML As String
origHTML = WebBrowser1.DocumentText
Dim newHTML As String
Dim regex As String = "<img.*/>"
newHTML = regex.Replace(origHTML, regex, "", regex.Multiline)
WebBrowser1.DocumentText = newHTML



感谢您的帮助.



Thanks for help.

推荐答案

我看了一下代码,您还没有声明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!


这篇关于禁用在Web浏览器控件中加载图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆