首页 > 解决方案 > 如何通过双击 HTML 表格行导航到另一个页面?

问题描述

我只能突出显示该行,但无法双击 TR 以触发事件并转到下一页。

这是我的 VBA 代码:

Set table = webpage.Document.getElementsByClassName("grid-mvc")(0).getElementsByTagName("div")(0).getElementsByTagName("table")(0).getElementsByTagName("tbody")(0).getElementsByTagName("tr")(0)
'Double Click on row


For Each RowElement In table.getElementsByClassName("grid-cell")
MsgBox RowElement.innerText
    RowElement.Click
    RowElement.Focus

     RowElement.FireEvent "ondblclick", 1, 2
      RowElement.Focus
     SendKeys "{ENTER}"



     RowElement.FireEvent ("ondbclick")
     SendKeys "{ENTER}"
     RowElement.FireEvent ("ondbclick")
     RowElement.FireEvent ("onmousedown")
       'RowElement.dispatchEvent ("ondblclick")
     SendKeys "{ENTER}"

RowElement.getElementsByTagName("td")(1).Click




    If Trim(RowElement.getElementsByTagName("td")(0).innerText) = Value Then


 MsgBox RowElement.textContent
RowElement.getElementsByTagName("td")(0).Click



End If
Next

HTML 代码:

<TBODY>
  <TR class="grid-row ">
    <TD class="grid-cell" data-name="FacilityID">49343</TD>
    <TD class="grid-cell" data-name="SubBrand">QQ</TD>
    <TD class="grid-cell" data-name="PMSType">OnQ</TD>
    <TD class="grid-cell" data-name="PMSAccountingID">ORNA       </TD>
    <TD class="grid-cell" data-name="PMSIDDesc"></TD>
    <TD class="grid-cell" data-name="AccountingIDFullAcct">
      <DIV class="GLAccount">99 90700 USD</DIV></TD>
    <TD class="grid-cell" data-name="AccountDescription">
      <DIV title="Charitable Contributions      " 
      class="GLAccountDesc">Charitable Contributions      </DIV></TD>
    <TD class="grid-cell" data-name="AccountingID">2861</TD>
    <TD class="grid-cell" data-name="StartDate">12/7/2018</TD>
    <TD class="grid-cell" data-name="EndDate">12/31/2078</TD>
    <TD class="grid-cell" data-name="CodeBlockSpecific">No</TD>
    <TD class="grid-cell" data-name="SystemDefault">No</TD>
    <TD class="grid-cell" data-name="PermissionLevel">Permitted</TD>
    <TD class="grid-cell" data-name="UserID">MERE</TD>
    <TD class="grid-cell" data-name="LastUpdateTime">
      <DIV class="LastUpdateTime">12/7/2018 11:02:00 PM</DIV></TD>
    <TD class="grid-cell" data-name="MgmtGroup">Franchised</TD>
    <TD class="grid-cell" data-name="AcctType">Franchised</TD>
    <TD class="grid-cell" data-name="FinSys">
      <DIV title="Franchise" class="FinancialSystem">Franchise</DIV></TD>
    <TD class="grid-cell" data-name="Inncode">SEACU</TD>
    <TD class="grid-cell" data-name="HotelName">
      <DIV title="The Charter Hotel  Seattle, WA" class="HotelName">The Charter 
      Hotel  Seattle, WA</DIV></TD></TR></TBODY></TABLE>
<DIV class="grid-footer">
<DIV class="grid-itemscount"><SPAN class="grid-itemscount-label">Total 
Count:</SPAN>                 <SPAN class="grid-itemscount-caption">1</SPAN>     
        </DIV></DIV></DIV></DIV></DIV></DIV>
<DIV id="MappingSearchFacilityIdDialog"></DIV>
<DIV id="ApplyBrandDefaultMappingDialog"></DIV>
<SCRIPT>

标签: htmlexcelvbainternet-explorer

解决方案


我可以看到您只使用 Click()。它不会双击,也不会触发任何事件。

要触发任何事件,您可以尝试使用如下代码。

objElement.click
objElement.FireEvent "ondblclick", 1, 2

参考:

如何在 VBA 中双击 Web 对象

Re: 双击 html 元素,vb6


推荐阅读