WPF使用webbrowser控件时,每次打开都显示“Web浏览器已经限制此文件显示可能访问您的计算机的活动内容“,解决办法

网上找了好多,包括改IE安全设置, 在webbrose里的网页加上代码<!-- saved from url=(0013)about:internet -->,都没有效果。

后来在MSDN上看到了解决办法。

 // Load HTML document as a stream
  Uri uri = new Uri(@"pack://application:,,,/HTMLDocumentWithScript.html", UriKind.Absolute);
  Stream source = Application.GetResourceStream(uri).Stream;
  // Navigate to HTML document stream
  this.webBrowser.NavigateToStream(source);

最后记得将相应的资源文件比如上面的HTMLDocumentWithScript.html 设置生成操作为resource !

原文地址:https://www.cnblogs.com/gbnw/p/5543526.html