如何在WebBrowser-Control中启用JavaScript?

时间:2018-07-12 12:04:09

标签: javascript c# post httprequest webbrowser-control

我正在尝试连接到一个网站,为此,我需要一个具有(启用)JavaScript的“浏览器”,否则服务器将拒绝该连接(在HTML文件中,诸如“ ...启用JavaScript以查看完整页面” ...”)。有人知道如何激活JavaScript吗?

void connect (string url){
  WebBrowser wb = new WebBrowser();
  //this enables JavaScript?
  wb.ObjectForScripting = true;      

  wb.Navigate(new Uri(url));

  //I know this could be an endless while 
  while (wb.ReadyState != WebBrowserReadyState.Complete)
  {
    System.Windows.Forms.Application.DoEvents();
  }      

  HtmlDocument doc = wb.Document;

  Console.Write(wb.DocumentText);
}

0 个答案:

没有答案