Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to block flash elements in the web browser control
    text
    copied!<p>I building a C# application with a WebBrowser control in it and and I am trying to figure out a way to get the flash content within the web page to not display as it is sucking up a <em>ton</em> of my CPU and memory. I've been trying to remove the <code>&lt;object&gt;</code> tag within the page (there's only one) by getting it via browser.Document.GetElementsByTagName("object") and setting its outerHtml to an empty string. It returns one element (confirmed by the Count property) but accessing the first element ([0]) gives an index out of range error. I've tried doing it via a foreach loop but nothing happens at all and there are no errors. If I try to retrieve <code>&lt;div&gt;</code> elements instead of <code>&lt;object&gt;</code> elements, the foreach loop runs. Am I doing something wrong here, is there a bug, or is there a better way to remove the flash content? Any help greatly appreciated.</p> <p>My code:</p> <pre><code>HtmlElementCollection flashElements = webBrowser.Document.GetElementsByTagName("object"); foreach (HtmlElement element in flashElements) { element.OuterHtml = ""; MessageBox.Show("Deleted"); } </code></pre> <p>By the way, this is being run <em>after</em> the DocumentCompleted event has been fired.</p> <p><strong>EDIT:</strong> I just figured out that while the DocumentCompleted event is being called, it is being called before JavaScript injects the flash content onto the page. I've tried a few "sleeping"-like methods but they all stop the web page from processing too. Any way to wait for more time (5 seconds or so) while the webpage continues to render?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload