&#169&#59; Ţĩмό Şąļσмāĸ

Hi all! I'm trying to implement an image blocker utility to my web browser. First version of that tool was made like this:

  1. Find all the <img></img> things from HTML code
  2. Remove all of them
  3. Generate a new site
But all in all I think that it's not so good that I first thought, so is there any other way to block those images when loading the web page. I'm trying to find a simple solution, but all help is welcome!


Thanks,
Timo Salomaki



Re: Windows Forms General Image blocker

Zhi-Xin Ye - MSFT

We can loop through HtmlDocument.Images collection and set all image sources to empty, something like this:

Code Snippet


private
void Form4_Load(object sender, EventArgs e)

{

this.webBrowser1.Navigate("http://www.microsoft.com");

this.webBrowser1.DocumentCompleted +=
new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);

}

void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)

{

foreach (HtmlElement el in this.webBrowser1.Document.Images)

{

el.SetAttribute("src", "");

}

}






Re: Windows Forms General Image blocker

Timo S

Thanks!