Javascript 错误:无法获取属性';显示';指未定义的或空的引用 函数dropOrderDropDown(){ var currentInThisElement=document.activeElement.id var currentInThisElement数组=currentInThisElement.split(“”) var foundOneToDrop=false; var haveOneCurrentSelected=false; var dropDownTempArray=新数组(); if((dropDownDivValuesString!=“”)| |(dropDownDivValuesString!=null)){ dropDownTempArray=dropDownDivValuesString.split(','); 对于(i=0;i
首先,我建议在Javascript 错误:无法获取属性';显示';指未定义的或空的引用 函数dropOrderDropDown(){ var currentInThisElement=document.activeElement.id var currentInThisElement数组=currentInThisElement.split(“”) var foundOneToDrop=false; var haveOneCurrentSelected=false; var dropDownTempArray=新数组(); if((dropDownDivValuesString!=“”)| |(dropDownDivValuesString!=null)){ dropDownTempArray=dropDownDivValuesString.split(','); 对于(i=0;i,javascript,Javascript,首先,我建议在文档上使用getElementById()。all文档。all的浏览器支持有限。然后,请记住style只获取内联样式属性。因此,如果您不声明style inline,就不会得到任何结果 如果您的问题仍然存在,请告诉我!很明显,这些行中的某一行的style属性为null或未定义:document.all[dropDownTempArray[i]+“\u hideThisControl”].style.display或if(document.all[dropDownTempArray[
文档上使用getElementById()
。all
文档。all
的浏览器支持有限。然后,请记住style
只获取内联样式属性。因此,如果您不声明style inline,就不会得到任何结果
如果您的问题仍然存在,请告诉我!很明显,这些行中的某一行的style属性为null或未定义:document.all[dropDownTempArray[i]+“\u hideThisControl”].style.display或if(document.all[dropDownTempArray[i]+“\u dropdown”].style.display但是我没有解决方案,不知道该做什么这已经在应用程序中使用了,我没有做任何更改。那么为什么会突然发生这种情况呢?将此属性添加到那些元素:
style='display:WHATEVER;'
。看看这是否不能阻止javascript错误。我正在使用数组,因此如何使用document.getElementById和我没有使用内联样式表我需要在哪里添加此样式属性?你能用一句话
告诉我id为的任何元素\u hideThisControl
<script language="javascript">
function dropOrderDropDown() {
var currentInThisElement = document.activeElement.id
var currentInThisElementArray = currentInThisElement.split('_')
var foundOneToDrop = false;
var haveOneCurrentSelected = false;
var dropDownTempArray = new Array();
if ((dropDownDivValuesString != "") || (dropDownDivValuesString != null)){
dropDownTempArray = dropDownDivValuesString.split(',');
for (i=0; i < dropDownTempArray.length - 1; i++){
if (acdf != dropDownTempArray[i]){
if (document.all[dropDownTempArray[i] + "_hideThisControl"] != null){
if (document.all[dropDownTempArray[i] + "_hideThisControl"].style.display != "none"){
if (document.all[dropDownTempArray[i] + "_dropdown"] != null){
if (document.all[dropDownTempArray[i] + "_dropdown"].style.display == "block"){
document.all[dropDownTempArray[i] + '_txtValue'].click();
}
}
}
}
}
}
}
acdf = "";
return true;
</script>