private void button1_Click(object sender, EventArgs e)
{
webBrowser1.Navigate(textBox1.Text);
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
WebBrowser web = (WebBrowser)sender;
richTextBox1.Text = web.DocumentText;
}
above is sample code.
it's giving all Text of Current Open, if contents is updated by JavaScript, it visible but Document.Text not update.
Please Help guys
I had the same problem. Use the following sample code:
IHTMLDocument2 doc = webBrowser1.Document.DomDocument as IHTMLDocument2;
string content = doc.body.innerText;
Also, add mshtml to the references of your project (if you dont know how to add the refernce, just google it).
Actually, whenever you use this code, the value in the doc
variable is the updated version of the contents of the webbrowser.
Good Luck
I would guess that the javascript that is executing on the page which is modifying the content is happening after the DocumentCompleted event; Perhaps you can try a different event such as 'Invalidated'.
The WebBrowser.DocumentText also many not reflect any changes to the DOM, and you may need to navigate the DOM through the WebBrowser.Document property.
http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.document.aspx