2015-12-17 67 views
-1

我想單擊表格中的導航鏈接,但無法使其工作。我曾嘗試單擊表內的鏈接

  • getElementByID
  • getElementsByClassName
  • getElementsByTagName

和所有想出空。

Set tbls = HTMLDoc.getElementByID("tabToggleTable") 

離開

tbls = Nothing 

下面是從網站上我在看(特別<td title="Provider Accounting Home Page")的部分:

<html> 
    <head> 
    <body onhelp="" onload="sfHomePageLoad();" onresize=""> 
    <div id="pagehider"> 
    <table width="100%" height="100%" border="0" cellSpacing="11" cellPadding="0"> 
     <colgroup> 
     <tbody> 
     <tr> 
     <td id="WorkListsColumn"> 
     <td id="TasksColumn"> 
      <table width="100%" height="100%" class="CUI-Table" cellSpacing="0" cellPadding="5"> 
      <tbody> 
      <tr height="15" class="CUI-SectionTitleBar"> 
      <tr height="40%" class="CUI-Section"> 
       <td style="border-top-color: #6c8cd9; border-top-width: 1px; border-top-style: solid;"> 
       <table width="100%" height="100%" class="CUI-Table" cellSpacing="0" cellPadding="0"> 
        <tbody> 
        <tr height="15" class="CUI-SectionTitleBar" style="padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px;"> 
        <tr height="100%" class="CUI-Section"> 
         <td style="border-top-color: #6c8cd9; border-top-width: 1px; border-top-style: solid;"> 
         <div id="PrimaryTasksGrid" style="width: 682px; height: 326px; overflow: auto;"> 
          <table width="100%" style="background-color: white;" border="0" cellSpacing="0" cellPadding="2"> 
          <tbody> 
           <tr class="CUI-TableGridLinesRow"> 
           <td title="Provider Accounting Home Page" class="CUI-TableGridLinesRow" id=" 39" onmouseover="javascript:colorRow(this)" onmouseout="unColorRow(this)" onmousedown="javascript:colorRowClick(this)" onclick="javascript:nodeOnClick(this);" IgfSessionSecurity="<1" IgfFwdCred="false" IgfText="Provider Accounting Home Page" IgfUrl="../Bin/SmsTntRequest.asp?action=StartBusinessProcess&name=ProviderAccountingHomePage&form=ProviderAccountingHomePage&&GSM=duAuQFBuIBQHBxEpBxP-ALj98ABtQ9rL:XezOC76g7axKlXthZBxb5rrcVbgPa5wMe7QmxBQWL18_" IgfType="2"> 
            <font face="Arial" size="2"> 
            Text - Provider Accounting Home Page 

Screenshot of HTML structure

回答

0

<td>元素,標題爲「提供會計主頁」有ID 39(帶有前導空格),所以你應該能夠選擇像這樣的元素:

Set td = HTMLDoc.getElementById(" 39") 

編輯:如此,顯然你發佈了確切的HTML結構,除了它嵌套在中的細節。這就需要你進入iframe來獲取你想要的元素。

Set iframe = HTMLDoc.getElementsByTagName("iframe").Item("tabWell0") 
Set td = iframe.contentWindow.document.getElementById(" 39") 
+0

當我嘗試,我得到TD =什麼 – cfuson

+0

@cfuson然後是'HTMLDoc'不是'HTMLDocument'對象,或者HTML是從您發佈的樣本不同。 –

+0

我可以使用Set td = HTMLDoc.getElementsbyTagname(「div」)並獲得響應,如果我嘗試設置td = HTMLDoc.getElementsbyTagname(「table」)它再次沒有任何結果 – cfuson