Javascript Firefox onkeypress事件未传入事件参数
我有下面的textarea HTML标记,我正在将运行时插入DOM中(我只展示了它插入后的外观),并且我将onkeypress事件设置为作为内联属性激发。然而,在Firefox中,当我按下某个键时,我得到一个“事件未定义”错误,因为它处于焦点位置Javascript Firefox onkeypress事件未传入事件参数,javascript,firefox,javascript-events,onkeypress,Javascript,Firefox,Javascript Events,Onkeypress,我有下面的textarea HTML标记,我正在将运行时插入DOM中(我只展示了它插入后的外观),并且我将onkeypress事件设置为作为内联属性激发。然而,在Firefox中,当我按下某个键时,我得到一个“事件未定义”错误,因为它处于焦点位置 <textarea rows="3" cols="70" type="text" name="resultsRename" value="" class="redlining_textContent_Dialog_textbox" dojoTyp
<textarea rows="3" cols="70" type="text" name="resultsRename" value="" class="redlining_textContent_Dialog_textbox" dojoType="dijit.forms.SimpleTextArea" id="labelText" propercase="false" style="width:auto;" onkeypress="return handleEnterKey(event,doFunc();">
function handleEnterKey(e, func)
{
//alert("hit key handler");
//alert(dojo.toJson(e));
var key = e.keyCode || e.which;
if (key == 13)
{
func();
return false;
}
else
{
return true;
}
}
。。。我输入handleEnterKey,将我的e参数设置为textarea对象。为什么没有向我传递事件对象?显然,这在IE及其全局事件对象中运行良好
我不知所措。帮帮我。。。你是我唯一的希望
handleEnterKey
甚至不应该被调用,因为您有语法错误
return handleEnterKey(event,doFunc();
应该是
return handleEnterKey(event,doFunc);
传递事件
肯定有效:
return handleEnterKey(event,doFunc);