【问题标题】:How to disable mailto popup in WebBrowser for Pocket PC .NET CF 3.5?如何在 Pocket PC .NET CF 3.5 的 WebBrowser 中禁用 mailto 弹出窗口?
【发布时间】:2011-04-20 06:25:05
【问题描述】:
出于安全原因,当用户在查看本地 html 文件的子类 WebBrowser 中单击弹出窗口时,我试图禁用 Outlook(或任何默认邮件客户端)的打开。我尝试将 DocumentText 替换为没有“mailto:”链接引用的版本,但这一直失败(无论我尝试什么,在设置 DocumentText 后,它一直停留在 about:blank 页面上)。
我的问题的最佳解决方案是完全禁用任何默认邮件客户端,通过注册表或其他方式,但我对任何我还没有尝试过的东西持开放态度。有什么想法吗?
【问题讨论】:
标签:
c#
.net
compact-framework
browser
pocketpc
【解决方案1】:
我能够通过覆盖 html 文件以不包含“mailto”引用来解决我的安全问题。文件被替换后,我简单地刷新了一下:
TextReader tr = File.OpenText(e.Url.LocalPath);
htmlFile = tr.ReadToEnd();
tr.Close();
tr.Dispose();
if (htmlFile.Contains("mailto:support@website.com"))
{
htmlFile = htmlFile.Replace("mailto:support@website.com", @"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();
}