vb调用Webbrowser技巧集3

1、页面滚动:


Private Sub Command2_Click()
WebBrowser1.Document.parentwindow.scrollby 0, 30
End Sub

Private Sub Form_Load()
WebBrowser1.Navigate "http://www.applevb.com"
End Sub

点击Command2就可以使当前页面向下滚动30像素

2、判断页面是否可以前进后退

Private Sub Command1_Click()
WebBrowser1.GoForward
End Sub

Private Sub Command2_Click()
WebBrowser1.GoBack
End Sub

Private Sub Form_Load()
WebBrowser1.Navigate "http://www.applevb.com"
End Sub

Private Sub WebBrowser1_CommandStateChange(ByVal Command As Long, ByVal Enable As Boolean)
If (Command = CSC_NAVIGATEBACK) Then
Command2.Enabled = Enable
End If
If (Command = CSC_NAVIGATEFORWARD) Then
Command1.Enabled = Enable
End If
End Sub

上面的command1是前进按钮,command2是后退按钮。

你可能感兴趣的:(vb)