VB calls WebBrowser skills 4

zhaozj2021-02-16  97

1. How to make the webpage do not have a scroll bar:

Private sub mnuscroll1_click () Note: After you can run webbrowser1.document.body.scroll = "no" without displaying the web page End Subprivate sub mnuscroll2_click () Note: Before you have completely displayed on the web page You can run webbrowser1.document.body.scroll = "auto" 'Show Scroll Bars End Sub

2, how to get the HTML selected in the page in the page:

Private Sub Command1_Click () Dim objSelection Dim objTxtRange Set objSelection = WebBrowser1.Document.selection If Not (objSelection Is Nothing) Then Set objTxtRange = objSelection.createRange If Not (objTxtRange Is Nothing) Then Debug.Print objTxtRange.htmlText Set objTxtRange = Nothing End IF set objselection = Nothing end ifend sub

Private Sub Form_Load () WebBrowser1.naVigate "http://www.applevb.com" end SUB

转载请注明原文地址:https://www.9cbs.com/read-11686.html

New Post(0)