How to disable mailto popup in WebBrowser for Pocket PC .NET CF 3.5?
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开发者_StackOverflow社区 (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?
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: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();
}
精彩评论