JavaScript调试器无法正常工作 [英] JavaScript debugger not working

查看:120
本文介绍了JavaScript调试器无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在VS2010中调试文本框keyPress / keyDown事件。但是,当我单击某个键时,不会触发函数ontxtPID(event)。我错过了什么?谢谢。

 <   asp:TextBox  < span class =code-attribute>   ID   =  txtPID    ClientID   =   txtPID    runat   =  server    class   =  styleTextBox1   工具提示  =  7个字符,例如A03B001    onkeyDow n   =  ontxtPID(event);    onkeyPress   =  ontxtPID(event) ;    MaxLength   =  7    MinLength   =  7   >  <   / asp:TextBox  >  

...
< script type = <小号pan class =code-keyword> text / javascript >
function ontxtPID(event){
debugger ;
var v = document .getElementById(' lblWarning');
if (v!= null ){
v.innerHTML = ' ';
}

var e1 = document .getElementById(' <%= txtPID.ClientID%>')。value;
if (e1.length == 7 ){
if (event.keyCode == 13 ){ // RETURN
event.keyCode = 9 ; // TAB
return event.keyCode;
} else {
document .getElementById(' txtPID')。focus();
}
}
}
< / script >

解决方案

 onkeyDown =   ontxtPID(event) 



除非在其他地方定义事件,否则在事件发生时可能未定义,因此在调用函数之前失败。

用值替换事件并重试或者只是删除它,因为事件代码可能是自动的。

< pre lang =java> onkeyDown = ontxtPID();


I want to debug a textbox keyPress / keyDown event in VS2010. However, when I click a key, the function ontxtPID(event) is not fired. Did I miss something? Thanks.

    <asp:TextBox ID="txtPID" ClientID="txtPID" runat="server" class="styleTextBox1" ToolTip="7 Characters, e.g. A03B001" onkeyDown="ontxtPID(event);" onkeyPress="ontxtPID(event);" MaxLength="7" MinLength="7" ></asp:TextBox>

...
    <script type="text/javascript">
        function ontxtPID(event) {
            debugger;
            var v = document.getElementById('lblWarning');
            if (v != null) {
                v.innerHTML = '';
            }

            var e1 = document.getElementById('<%=txtPID.ClientID%>').value;
            if (e1.length == 7) {
                if (event.keyCode == 13) {      // RETURN
                    event.keyCode = 9;          // TAB
                    return event.keyCode;
                }   else {
                    document.getElementById('txtPID').focus();
                }
            }
        }
    </script>

解决方案

onkeyDown="ontxtPID(event)


Unless event is defined somewhere else, if likely to be undefined at time of event, thus failing before calling the function.
Replace event with a value and try again or simply remove it since the event code is probably automatic.

onkeyDown="ontxtPID();"


这篇关于JavaScript调试器无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆