我正在开发一个带有WebBrowser控件的Windows应用程序,该控件可导航到sharepoint站点.
我的问题是我收到了JavaScript错误.
如何禁用JavaScript错误?我不想让它们弹出来.
我想用它来调用网页上的一些JS脚本.我有这个:
static void Stuff()
{
WebBrowser browser = new WebBrowser();
browser.Navigate("http://www.iana.org/domains/example/");
HtmlDocument doc = browser.Document;
//doc.InvokeScript("someScript");
Console.WriteLine(doc.ToString());
}
static void Main(string[] args)
{
Console.WriteLine("hi");
var t = new Thread(Stuff);
t.SetApartmentState(ApartmentState.STA);
t.Start();
}
Run Code Online (Sandbox Code Playgroud)
问题1:当我尝试获取时,我得到"对象引用未设置"异常doc.ToString().为什么?
问题2:如何从HTML文档中将一些数据导入主程序?WebBrowser需要一个单独的线程,这需要一个不能返回任何值的静态方法.如何返回,比如说,doc在Main()这样我就可以用它做什么?
我正在开发一个Internet Explorer命令按钮,该按钮将在单击后打开特定的网页.这是一段代码(IEApp是对实例的引用IE.WebBrowser):
IEApp.Navigate(sURL, ref one, ref two, ref three, ref four);
Run Code Online (Sandbox Code Playgroud)
上面的行抛出以下COMException:
Exception Source: Interop.SHDocVw
Exception Type: System.Runtime.InteropServices.COMException
Exception Message: The requested resource is in use. (Exception from HRESULT: 0x800700AA)
Exception Target Site: Navigate
Run Code Online (Sandbox Code Playgroud)
这在IE6或IE7上不是问题.什么出问题的任何想法?我正在使用AddInExpress来创建命令按钮.
干杯! 基督教
我正在开发一个C#,.NET Framework 4.0应用程序.它通过订单访问某些页面.有时我必须移动到下一页而不等待前一页完成工作.如何取消WebBrowser元素的上一个导航过程?
WebBrowserelement使用Internet Explorer.谢谢.
这就是我的导航方式
webBrowser1.Navigate("http://www.mywebsite.com/");
Run Code Online (Sandbox Code Playgroud) c# ×3
browser ×2
.net ×1
comexception ×1
exception ×1
navigateurl ×1
navigation ×1
winforms ×1