如何在 Pocket PC .NET CF 3.5 的 WebBrowser 中禁用 mailto 弹出窗口?

发布于 2024-11-02 10:39:22 字数 251 浏览 10 评论 0原文

出于安全原因,当用户单击我的子类 WebBrowser 中查看本地 html 文件的弹出窗口时,我尝试禁用 Outlook(或任何默认邮件客户端)的打开。我尝试将 DocumentText 替换为没有“mailto:”链接引用的版本,但这一直失败(无论我尝试什么,设置 DocumentText 后它都会坚持到 about:blank 页面)。

解决我的问题的最佳解决方案是通过注册表或其他方式完全禁用任何默认邮件客户端,但我愿意接受我尚未尝试过的任何内容。有什么想法吗?

For security reasons, I'm trying to disable the opening of Outlook (or any default mail client) when the user clicks a popup in my subclassed WebBrowser viewing a local html file. I've tried replacing the DocumentText with a version sans the "mailto:" link references, but this has continuously failed (no matter what I try, it keeps sticking to the about:blank page after setting the DocumentText).

The best solution to my problem would be to completely disable any default mail clients, via the registry or other means, but I am open to anything I haven't tried yet. Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

妳是的陽光 2024-11-09 10:39:22

我能够通过覆盖 html 文件以不包含“mailto”引用来解决我的安全问题。文件替换后,我简单刷新一下:

  TextReader tr = File.OpenText(e.Url.LocalPath);
  htmlFile = tr.ReadToEnd();
  tr.Close();
  tr.Dispose();

  if (htmlFile.Contains("mailto:[email protected]"))
  {
      htmlFile = htmlFile.Replace("mailto:[email protected]", @"about:blank");

      //Recreate new file with fixed html
      File.Delete(e.Url.LocalPath);
      TextWriter tw = File.CreateText(e.Url.LocalPath);
      tw.Write(htmlFile);
      tw.Flush();
      tw.Close();
      tw.Dispose();

      Refresh();
  }

I was able to fix my security issue by overwriting the html file to contain no "mailto" references. After the file is replaced, I simply refreshed it:

  TextReader tr = File.OpenText(e.Url.LocalPath);
  htmlFile = tr.ReadToEnd();
  tr.Close();
  tr.Dispose();

  if (htmlFile.Contains("mailto:[email protected]"))
  {
      htmlFile = htmlFile.Replace("mailto:[email protected]", @"about:blank");

      //Recreate new file with fixed html
      File.Delete(e.Url.LocalPath);
      TextWriter tw = File.CreateText(e.Url.LocalPath);
      tw.Write(htmlFile);
      tw.Flush();
      tw.Close();
      tw.Dispose();

      Refresh();
  }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文