Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在internet explorer或.NET webbrowser控件中阻止iFrame_C#_.net_Internet Explorer_Iframe_Webbrowser Control - Fatal编程技术网

C# 如何在internet explorer或.NET webbrowser控件中阻止iFrame

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

我需要一些帮助来阻止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.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或完全禁用脚本。