1

我有一个带有 WebBrowser 控件的 Access 2010 表单,我想从呈现的 HTML 中删除一个提交按钮。当我阅读 HTML 时,我的 WebBrowser 控件工作正常,但在尝试更改呈现的内容时出现错误。我尝试了几种方法,它们都返回“需要对象”错误。我有很多使用 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

提前致谢!

4

1 回答 1

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
于 2013-09-16T22:03:39.930 回答