Disable loading of images in WebBrowser control

  • Thread starter Thread starter Jeff Caton
  • Start date Start date
Hello!
How can I disable loading images in the webbrowser control?

There's no built-in method or property do disable images from being
loaded in webbrowser control which relies on IE. And modifying "src"
attribute of "img" tag may not be enough as the images may come from
dynamically from different servers. So, another solution can be
tweaking registry to disable images from being loaded, note that this
setting also effects regular Internet Explorer. So, you may re-set it
to False as follows:

' Set Display Inline Images value to false
Dim regkey As Microsoft.Win32.RegistryKey = _
My.Computer.Registry.CurrentUser
regkey.OpenSubKey("Software\Microsoft\Internet Explorer\Main", _
True).SetValue("Display Inline Images", "no")

Keep in mind that writing to registry requires administrative rights.

HTH,

Onur Güzel
 
what about a 2 pass procedure?
u load the html page using webclient, then you can remove all the unwanted
tags , then you load the code into a webbrowser control :)

That will only work with pure-HTML. Think of a page that should
retrieve images or any visual content dynamically, that is, while page
is open, using some script. At that time, newer content than the
loaded content (content, whose img tags are removed) will bring
images. Worse, there may be other elements in document such as links
which have the non-absolute targets (hrefs), like "page.html" rather
than "http://somedomain.com/page.html". When you download a file onto
a local disk (let's say c:\), browser will try locating link's target
at: c:\page.html" which is not available.

So, disabling images using registry before launching application is
wiser to approach. Restore it on app shutdown, as well.

Onur Güzel
 
Back
Top