0
<DIV class="uiMenu uiSelectorMenu" role=menu>
<UL class=uiMenuInner bindPoint="menu">
<LI class="uiMenuItem uiMenuItemRadio uiSelectorOption  checked" data-label="Paused"><A aria-checked=true class=itemAnchor role=menuitemradio tabIndex=0 href="#" rel=ignore><SPAN class="itemLabel fsm"><SPAN class=icon_wrap><IMG class="selector icon" src="/images/adz/ad_states/paused.gif"></SPAN>Paused</SPAN></A></LI>
<LI class="uiMenuItem uiMenuItemRadio uiSelectorOption " data-label="Active"><A aria-checked=true class=itemAnchor role=menuitemradio tabIndex=1 href="#" rel=ignore><SPAN class="itemLabel fsm"><SPAN class=icon_wrap><IMG class="selector icon" src="/images/adz/ad_states/running.gif"></SPAN>Active</SPAN></A></LI>
<LI class="uiMenuItem uiMenuItemRadio uiSelectorOption " data-label="Deleted"><A aria-checked=true class=itemAnchor role=menuitemradio tabIndex=2 href="#" rel=ignore><SPAN class="itemLabel fsm"><SPAN class=icon_wrap><IMG class="selector icon" src="/images/adz/ad_states/deleted.gif"></SPAN>Deleted</SPAN></A></LI></UL></DIV></DIV><SPAN bindPoint="copy_link_wrapper"><A class=copy_link href="#"></A></SPAN></DIV><SELECT bindPoint="select"><OPTION value=""></OPTION><OPTION selected value=2>Paused</OPTION><OPTION value=1>Active</OPTION><OPTION value=99>Deleted</OPTION></SELECT> </DIV></TD>
<TD id=td_time_start_html_last_row class=td_time_start_html ?>

上記は、変更したいドロップダウンメニューの HTML コードです。

コードの最後にはSELECT、OPTIONなどがあります。通常は変更できますが、selectedIndexを変更してもWebサイトでは何もしません。コードの最初の部分に何かがあると想定していますそれをしてください。

これが私のVB6コードです(どの言語でも表示できることに注意してください)

For i = 0 To Form1.WebBrowser1.Document.All.length - 1 '
    If Form1.WebBrowser1.Document.All.Item(i).nodeName = "SELECT" Then
        For x = 0 To Form1.WebBrowser1.Document.All.Item(i).Options.length - 1
            If InStr(Form1.WebBrowser1.Document.All.Item(i).Options(x).Text, "Active") > 0 Then
                Form1.WebBrowser1.Document.All.Item(i).selectedIndex = x
            End If
        Next x
    End If
Next i

そのコードを実行し、Debug.Print Form1.WebBrowser1.Document.All.Item(i).Options(x).Selected でアイテムの値を確認すると、true が返され、前の選択は false と表示されますが、ウェブサイトのアイテムは変更/更新されません。

どんな助けでも大歓迎です。

4

2 に答える 2

1

オプションの .selected プロパティを使用します。これにより、select の .selectedIndex が自動的に更新されます。POC.HTA:

<html>
 <head>
  <Title>select</Title>
  <hta:application id="select" scroll = "no">
  <script type="text/vbscript">
   Function doIt()
     ' select Item2
     With document.getElementById("lbDemo")
       MsgBox "Before: " & .selectedIndex
       .options(1).selected = True
       MsgBox "After: " & .selectedIndex
     End With
   End Function
  </script>
 </head>
 <body>
  <select id="lbDemo" size="4">
   <option value=Item1>Item1</option>
   <option value=Item2>Item2</option>
   <option value=Item3>Item3</option>
  </select>
  <hr />
  <input type="button" value="select 2" onclick="doIt" />
 </body>
</html>
于 2013-08-23T13:45:14.607 に答える