Pmillan
Pmillan

Reputation: 573

How to blocking iframes in internet explorer or .NET webbrowser control

I need some help to blocking iframes in internet explorer or .NET webbrowser control. I tried security preferences, that doesn't worked. XP and IE8, with .NET Framework 4.0

Upvotes: 1

Views: 1154

Answers (1)

Ry-
Ry-

Reputation: 224962

In the DocumentCompleted event for your WebBrowser, simply remove all the <iframe> elements:

foreach(HtmlElement x in ((WebBrowser) sender).Document.GetElementsByTagName("iframe")) {
    x.OuterHtml = String.Empty;
}

Upvotes: 6

Related Questions