C# 如何在internet explorer或.NET webbrowser控件中阻止iFrame
我需要一些帮助来阻止internet explorer或.NET webbrowser控件中的iFrame。我试过安全偏好,但没用。XP和IE8,在WebBrowser的DocumentCompleted事件中使用.NET Framework 4.0,只需删除所有元素:C# 如何在internet explorer或.NET webbrowser控件中阻止iFrame,c#,.net,internet-explorer,iframe,webbrowser-control,C#,.net,Internet Explorer,Iframe,Webbrowser Control,我需要一些帮助来阻止internet explorer或.NET webbrowser控件中的iFrame。我试过安全偏好,但没用。XP和IE8,在WebBrowser的DocumentCompleted事件中使用.NET Framework 4.0,只需删除所有元素: foreach(HtmlElement x in ((WebBrowser) sender).Document.GetElementsByTagName("iframe")) { x.OuterHtml = String
foreach(HtmlElement x in ((WebBrowser) sender).Document.GetElementsByTagName("iframe")) {
x.OuterHtml = String.Empty;
}
在WebBrowser的DocumentCompleted事件中,只需删除所有元素:
foreach(HtmlElement x in ((WebBrowser) sender).Document.GetElementsByTagName("iframe")) {
x.OuterHtml = String.Empty;
}
你可以通过删除一些加载事件中的iframe来修改DOM。你能给我链接一些好的教程或什么吗?我不知道你可以通过删除加载事件中的iframe来修改DOM。你能给我链接一些好的教程吗?我不知道DOM+1 OP也想要一个IE解决方案。我的想法是在Internet功能控件中搜索这样一个选项,但找不到任何选项。短,容易和工作!谢谢你,这解决了我的问题+1.这可能是最好的近似值。请注意,在加载页面时需要定期运行此代码,以删除JavaScript创建的iFrame或完全禁用脚本。+1 OP也需要IE的解决方案。我的想法是在Internet功能控件中搜索这样一个选项,但找不到任何选项。短,容易和工作!谢谢你,这解决了我的问题+1.这可能是最好的近似值。请注意,在加载页面时需要定期运行此代码,以删除JavaScript创建的iframe或完全禁用脚本。