1
我使用Delphi和WebBrowser組件來瀏覽html頁面。該頁面有一個Combobox。有什麼辦法可以調用OnChange事件嗎?如何調用「選擇」的OnChange事件? (Delphi - WebBrowser)
組合框是這樣的:
<select name="comboname" onchange="Some Javascript codes">
而且,我已經使用這個代碼:
function TFrmMain.SetComboboxValue(WB: TEmbeddedWB;
SelectName, ItemName: string): Boolean;
var
iForms, iFormItems, iSelectItems: Word;
FormItem: OleVariant;
begin
Result := false;
for iForms := 0 to WB.OleObject.Document.Forms.length - 1 do
begin
FormItem := WB.OleObject.Document.Forms.item(iForms);
for iFormItems := 0 to FormItem.length - 1 do
begin
if (FormItem.item(iFormItems). type = 'select-one') and SameText
(FormItem.item(iFormItems).Name, SelectName) then
begin
for iSelectItems := 0 to FormItem.item(iFormItems).Options.length - 1 do
begin
if SameText(FormItem.item(iFormItems).Options.item(iSelectItems)
.Text, ItemName) then
begin
FormItem.item(iFormItems).SelectedIndex := iSelectItems;
Result := true;
Break;
end;
end;
end;
end;
end;
end;
但它只能改變數值。
謝謝你,更簡單的方法? :d – Kermia 2010-09-16 08:58:16