I am trying to write a 'win app' that is connecting to a web page. you suppose this is the html page
<a href="javascript:fun(p)">click me</a>
<a href="javascript:go('N')">Next</a>
I want to load this page on a WebBrowser control and find hyperlinks within that. after that add them into a ListView control. I am ok by first links but I have problem with navigating to the next page.
this is my c# code :
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
HtmlElementCollection col = webBrowser1.Document.GetElementsByTagName("a");
int i = 1;
foreach (HtmlElement item in col)
{
if (item.GetAttribute("href").Contains("go"))
{
object[] o = new object[1];
o[0] = "N";
object res = this.webBrowser1.Document.InvokeScript("go", o);
}
else
{
ListViewItem lvi = listView1.Items.Add(item.InnerText);
lvi.SubItems.Add(item.GetAttribute("href"));
toolStripStatusLabel1.Text = i.ToString();
i++;
}
}
}
I get this error
and it doesn't invoke javascript function and I can't go to the next page by calling javascript function.
I guess it is because of WebBrowser. I think The WebBrowser doesn't load completely.
Now I am completely confused how can I fix the problem. I will appreciate any help or suggestion and finally I am sorry for my poor English.