|
|
Title | Get all text or the selected text from a WebBrowser control by using the control's methods |
Description | This example shows how to get all text or the selected text from a WebBrowser control by using the control's methods in Visual Basic 6. |
Keywords | WebBrowser, browser, internet, text, selected text |
Categories | Tips and Tricks, Controls |
|
|
Thanks to James Hansen.
The program uses the WebBrowser control's Document object represents the Web page loaded. That object's Body property refers to the entire Web page. The ActiveElement property refers to the selected text. The program uses those objects' InnerText, OuterText, InnerHtml, and OuterHtml properties to learn about the Web page's text and the selected text.
|
|
' Grab text from the WebBrowser control.
Private Sub Command1_Click()
txtResult(1).Text = WebBrowser1.Document.Body.InnerText
txtResult(2).Text = WebBrowser1.Document.Body.OuterText
txtResult(3).Text = WebBrowser1.Document.Body.InnerHtml
txtResult(4).Text = WebBrowser1.Document.Body.OuterHtml
txtResult(5).Text = _
WebBrowser1.Document.ActiveElement.InnerText
txtResult(6).Text = _
WebBrowser1.Document.ActiveElement.OuterText
txtResult(7).Text = _
WebBrowser1.Document.ActiveElement.InnerHtml
txtResult(8).Text = _
WebBrowser1.Document.ActiveElement.OuterHtml
End Sub
|
|
|
|
|
|