比较简单的一个方法:先在项目中添加一个.txt文件,在里面写需要的html代码JavaScript代码,然后按如下代码引用即可:
string str = null;
StreamReader sr = new StreamReader(@"D:\Backup\我的文档\Visual Studio 2008\Projects\MessagePhoto\Html.txt", Encoding.Default);
webBrowser1.Navigate("about:blank");
webBrowser1.IsWebBrowserContextMenuEnabled = false;//屏蔽网页的右键菜单
webBrowser1.Document.OpenNew(true);
str = sr.ReadToEnd();
webBrowser1.Document.Write(str);
StreamReader sr = new StreamReader(@"D:\Backup\我的文档\Visual Studio 2008\Projects\MessagePhoto\Html.txt", Encoding.Default);
webBrowser1.Navigate("about:blank");
webBrowser1.IsWebBrowserContextMenuEnabled = false;//屏蔽网页的右键菜单
webBrowser1.Document.OpenNew(true);
str = sr.ReadToEnd();
webBrowser1.Document.Write(str);