获取组合框值的Javascript在IE11中有效,但在Edge中不起作用
我有一组javascript函数,它们在IE11中正常工作,但在Edge中却不能正常工作,我不确定需要修改什么来整理它们。我使用选择框的Id调用它们获取组合框值的Javascript在IE11中有效,但在Edge中不起作用,javascript,microsoft-edge,Javascript,Microsoft Edge,我有一组javascript函数,它们在IE11中正常工作,但在Edge中却不能正常工作,我不确定需要修改什么来整理它们。我使用选择框的Id调用它们 function getComboValue (combo) { if (typeof (combo) == "string") combo = getComboById (combo); // If no combo can be found return undefined if (
function getComboValue (combo)
{
if (typeof (combo) == "string")
combo = getComboById (combo);
// If no combo can be found return undefined
if (!combo)
return;
if (isDHTMLCombo (combo))
{
var sVal = combo.getActualValue ();
if ((sVal != null) && (sVal != 'null'))
return sVal;
}
else
{
var selIdx = combo.selectedIndex;
if (selIdx > -1)
{
var selValue = combo.options[selIdx].value;
return selValue;
}
}
return '';
}
function getComboById (id)
{
var combo = document.getElementById (id);
if (combo && combo.tagName == "INPUT")
{
// DHTML combo is returned if the id is of a DHTML combo box.
var par = combo.parentNode;
if (par)
{
// Get the parent object
combo = par.combo;
}
}
return combo;
}
function isDHTMLCombo (combo)
{
if (typeof (combo) == "string")
combo = getComboById (combo);
if (!combo)
return false;
if (combo.DOMelem_input != undefined)
{
// Seems to be DHTML
return true;
}
if (combo.getAttribute ("igIsDHTML") != null)
{
// Seems to be DHTML
return true;
}
return false;
}
我如何调整这些,以便在Edge中返回正确的信息-getComboValue正在返回“”目前combo元素和函数不是HTML/JS标准,您必须将边缘导航器置于IE模式您是否使用DHTMLX:JavaScript UI框架?如果是这样,你能提供更多的相关代码吗?我无法重现您的问题,因为html代码缺失,我不确定它是否会影响测试结果。如果需要在
onchange
事件中获取值,则只需定义attachEvent
,您可以参考以下简单示例:。