如何在webbrowser控件中禁用图像

时间:2022-06-07 20:45:03

in vb.net 2003 , how to disable images loading in webbrowser control

在vb.net 2003中,如何在webbrowser控件中禁用图像加载

1 个解决方案

#1


The way I have done this in the past is using Regex to replace image tags with empty quotes. Give the following a try, stick it into your DocumentLoaded event, or such:

我过去这样做的方法是使用Regex用空引号替换图像标签。试试以下内容,将其粘贴到DocumentLoaded事件中,或者这样:

origHTML = webBrowser.DocumentText
Dim newHTML as String

Dim regex as String = "<img.*/>"

newHTML = Regex.Replace(origHTML, regex, "", RegexOptions.Multiline)
webBrowser.DocumentText = newHTML

This should solve your problem.

这应该可以解决您的问题。

Best Regards

#1


The way I have done this in the past is using Regex to replace image tags with empty quotes. Give the following a try, stick it into your DocumentLoaded event, or such:

我过去这样做的方法是使用Regex用空引号替换图像标签。试试以下内容,将其粘贴到DocumentLoaded事件中,或者这样:

origHTML = webBrowser.DocumentText
Dim newHTML as String

Dim regex as String = "<img.*/>"

newHTML = Regex.Replace(origHTML, regex, "", RegexOptions.Multiline)
webBrowser.DocumentText = newHTML

This should solve your problem.

这应该可以解决您的问题。

Best Regards