c# - 如何在 Internet Explorer 或 .NET Web 浏览器控件中阻止 iframe

标签 c# .net internet-explorer iframe webbrowser-control

我需要一些帮助来阻止 Internet Explorer 或 .NET 网络浏览器控件中的 iframe。我尝试了安全首选项,但没有用。 XP 和 IE8,带有 .NET Framework 4.0

最佳答案

DocumentCompleted为您举办的事件 WebBrowser , 只需删除所有 <iframe>元素:

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

关于c# - 如何在 Internet Explorer 或 .NET Web 浏览器控件中阻止 iframe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8565733/

相关文章:

c# - 使用测试服务器的 .NET 6 E2E 测试在 TeamCity CI 上失败,但工作手动运行

c# - 在 WPF 中完成拖动时创建上下文菜单

c# - OLEDB 参数化查询

javascript - 使用javascript退出IE 10或更低版本的全屏模式

javascript - 在 IE 中需要双击打开下拉菜单,在 Chrome 中工作正常

c# - 当 ObservableCollection 触发 CollectionChanged 时,ItemsControl 不会自行更新

c# - 为什么动态对象的赋值会抛出 RuntimeBinderException?

c# - 将 List<Object> 转换为 ObservableCollection<Object> 的最佳方式

c# - Paypal IPN 获取 405 : method not allowed

javascript - 使用 Javascript 在 Mozilla 和 IE 中返回 NaN 的日期