gpt4 book ai didi

javascript - 单击下拉列表中的子 DIV

转载 作者:行者123 更新时间:2023-12-03 02:52:21 26 4
gpt4 key购买 nike

我已经成功地在 Internet Explorer 中通过 Excel VBA 启用了下拉菜单,但是我无法单击第二个子 DIV。虽然我可以 debug.print 下拉列表的内容,但我无法管理内部 DIV 上的 fireevent 。这是我正在处理的源代码以及我到目前为止所做的事情。

<div style="border-width: 1px; z-index: 1018; visibility: visible; height: 238px; width: 304px; left: 1566px; top: 144px;" role="presentation" id="x-auto-1048" class="x-combo-list x-ignore x-component x-border "><div tabindex="0" hidefocus="true" id="x-auto-318" class=" x-view x-combo-list-inner x-component  x-unselectable" style="overflow-x: hidden; padding: 0px; border-width: 0px; height: 238px; width: 304px;" unselectable="on">   <div class="x-combo-list-item x-panel-header ">&nbsp;Actions</div><div class="x-combo-list-item ">Add Lead Disposition</div><div class="x-combo-list-item  x-view-highlightrow x-combo-selected">Add Lead Assignment Priority</div><div class="x-combo-list-item x-panel-header ">Audits</div><div class="x-combo-list-item ">Account Settings</div><div class="x-combo-list-item x-panel-header ">Actions</div><div class="x-combo-list-item ">Add Lead Disposition</div><div class="x-combo-list-item ">Add Lead Assignment Priority</div><div class="x-combo-list-item x-panel-header ">Audits</div><div class="x-combo-list-item ">Account Settings</div></div></div>

这就是我到目前为止所做的

Private Sub CommandButton2_Click()
Dim ie As Object
Dim button As Variant
Dim var As String: var = ActiveCell.Value


Dim disp As Object
Dim dis As Object
Dim innnerr As Variant
Dim i As Long: i = 0
ReDim innnerr(1000)
Set ie = CreateObject("internetexplorer.application")
ie.Visible = True
With ie
.Visible = True
.navigate "http://controlpanel.sukutrade.verio/index.html#account-overview?sukuAccountUsername=" & var
While .readyState = READYSTATE_COMPLETE
Wend
End With
'Wait some to time for loading the page
While ie.Busy
DoEvents
Wend
Application.Wait (Now + TimeValue("0:00:02"))

ie.document.getElementById("x-auto-317-input").Click



Set disp = ie.document.getElementById("x-auto-1048").getElementsByTagName("div")


For Each dis In disp
innnerr(i) = dis.innerText
If dis.innerText = "Add Lead Disposition" Then dis.fireevent "onclick"
i = i + 1: Exit For
Next dis


Application.Wait (Now + TimeValue("0:00:02"))


ie.Quit
End Sub

我需要的是单击具有内部文本“添加潜在客户处置”的第二个子项。

编辑:根据我在下面得到的答案,迭代工作正常,但是 Click 事件没有触发。我尝试了 .FocusOnclick 以及 FireEvent 但没有解决方案。如有任何帮助,我们将不胜感激。

最佳答案

你试过这样吗?它应该可以工作。

Dim post As Object

For Each post In IE.document.getElementsByClassName("x-combo-list-item")
If InStr(post.innerText, "Add Lead Disposition") > 0 Then post.Click: Exit For
Next post

关于javascript - 单击下拉列表中的子 DIV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47790001/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com