我有一个带有WebBrowser控件的Access 2010表单,我想从呈现的HTML中删除“提交”按钮。我正在阅读HTML时,我的WebBrowser控件正常工作,但在尝试更改渲染内容时出现错误。我尝试了几种方法,它们都返回“Object Required”错误。我有很多使用WebBrowser控件的工作代码,因此我不愿意将其更改为另一个控件。无论如何使用此控件执行此操作?
以下是最新代码的摘录:
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Dim strLook As String
Dim doc As HTMLDocument
Set doc = WebBrowser1.Document
Dim txtInner
strLook = "<input type=""submit"" name=""subaction"" value=""Force"" class=""inputfield"">"
txtInner = WebBrowser1.Document.Body.innerHTML
txtInner = Replace(txtInner, strLook, "")
Webrowser1.Document.Body.innerHTML = txtInner
End Sub
提前致谢!
答案 0 :(得分:0)
类似的东西:
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Dim doc As HTMLDocument
Dim els
Set doc = WebBrowser1.Document
Set els = doc.getElementsByTagname("input")
For Each el In els
If el.Value = "Force" And el.className = "inputfield" Then
el.ParentNode.RemoveChild el
Exit For
End If
Next el
End Sub