public static class WebBrowserExtensions
{
public static void SuppressScriptErrors(this WebBrowser webBrowser, bool hide)
{
FieldInfo fiComWebBrowser = typeof(WebBrowser).GetField("_axIWebBrowser2", BindingFlags.Instance | BindingFlags.NonPublic);
if (fiComWebBrowser == null) return;
object objComWebBrowser = fiComWebBrowser.GetValue(webBrowser);
if (objComWebBrowser == null) return;
objComWebBrowser.GetType().InvokeMember("Silent", BindingFlags.SetProperty, null, objComWebBrowser, new object[] { hide });
}
}
wpf 浏览器控件扩展方法 屏蔽js错误提示的..
顺便说下..获取某些 页面的 html ...
string URL = "http://www.windowsphone.com/en-US/apps/5d892e5b-5fb0-4de6-8e44-62b72eb9fc1c";
private void wb_LoadCompleted(object sender, NavigationEventArgs e)
{
if (wb.Document != null)
{
if (flag)
{
mshtml.IHTMLDocument2 doc2 = (mshtml.IHTMLDocument2)wb.Document;
string html = doc2.body.innerHTML;
ParseURL(html);
}
flag = true;
}
}
用 webbroswer 获取 某些获取不到真html页面的 html.....
这里需要引用一个 dll 在 C:\Program Files\Microsoft.NET\Primary Interop Assemblies\Microsoft.mshtml.dll