我在js中定义了一个函数:function closeCodeList()
{
try
{
showFistIndex = 0;
arrayBmCode = null;
if(document.all("spanCode").style.display=='')
{
var disFlag=1;
}
document.all("spanCode").style.display='none';
try{if(disFlag)oldFieldKey.focus();}catch(ex){}
}
catch(ex)
}然后调用的时候
Field.onblur=closeCodeList();运行时提示:“错误:尚未实现”我把括号去掉后又能正常调用,为什么这里调用函数不能用括号呢?
{
try
{
showFistIndex = 0;
arrayBmCode = null;
if(document.all("spanCode").style.display=='')
{
var disFlag=1;
}
document.all("spanCode").style.display='none';
try{if(disFlag)oldFieldKey.focus();}catch(ex){}
}
catch(ex)
}然后调用的时候
Field.onblur=closeCodeList();运行时提示:“错误:尚未实现”我把括号去掉后又能正常调用,为什么这里调用函数不能用括号呢?
函数的定义是 function fun(){..} 或者 var fun = fnction(){}
Field.onblur期待的是函数句柄,即 fun,而不是调用fun()后的返回值(除非返回的也是函数句柄)
try
{
showFistIndex = 0;
arrayBmCode = null;
if(document.all("spanCode").style.display=='')
{
var disFlag=1;
}
document.all("spanCode").style.display='none';
try{if(disFlag)oldFieldKey.focus();}catch(ex){}
}
catch(ex) }