使用VBA执行javascript函数

使用VBA执行javascript函数,javascript,html,vba,Javascript,Html,Vba,我正在尝试使用VBA执行javascript函数,但没有成功 我在列表框中选择一个项目 我的目标:选择项目后刷新结果 VBA: IEdoc_NEW2.getElementById("native_dropdown_selected_size_name").selectedIndex = 1 Call IEdoc_NEW2.parentWindow.execScript("dummySubmitButton()", "JavaScript") HTML: IEdoc_NEW2.getElemen

我正在尝试使用VBA执行javascript函数,但没有成功

我在列表框中选择一个项目

我的目标:选择项目后刷新结果

VBA:

IEdoc_NEW2.getElementById("native_dropdown_selected_size_name").selectedIndex = 1
Call IEdoc_NEW2.parentWindow.execScript("dummySubmitButton()", "JavaScript")
HTML:

IEdoc_NEW2.getElementById("native_dropdown_selected_size_name").selectedIndex = 1
Call IEdoc_NEW2.parentWindow.execScript("dummySubmitButton()", "JavaScript")

塞朗纳
s
M
L
JavaScript:

IEdoc_NEW2.getElementById("native_dropdown_selected_size_name").selectedIndex = 1
Call IEdoc_NEW2.parentWindow.execScript("dummySubmitButton()", "JavaScript")
if(typeof(TwisterNonJs)==“未定义”){
window.TwisterNonJs={};
TwisterNonJs.handleDropDown=[];
}
TwisterNonJs.handleDropDown[1]=函数(){
var twisterUpdateButton=“submit.twisterUpdateButton_1”
document.getElementById(“dummySubmitButton”).setAttribute(“name”,twisterUpdateButton);
document.forms['twister'].submit();
};
document.getElementById(“本机\下拉\选定\大小\名称”).onchange=function(){
TwisterNonJs.handleDropDown[1]();
};
但这不起作用。

请尝试更改fireEvent

IEdoc_NEW2.getElementById("native_dropdown_selected_size_name").FireEvent "onchange"
您还可以尝试添加一个事件,然后触发它

Dim evt As Object
Set evt = .document.createEvent("HTMLEvents")
evt.initEvent "change", True, False

IEdoc_NEW2.querySelector("#native_dropdown_selected_size_name").dispatchEvent evt