开发者

javascript key down problem

I have a key down event attached to one of my textboxes and over time and modifications/additions of 3rd party scripts the key down doesn't work any more. I've tried replacing key down with key up/key press but no luck.

How would you trouble shoot something like this (开发者_如何转开发to me, it's like a needle in the haystack).


in your Javascript code where you handle the KeyDown event, add "debugger" before your code, and you'll be able to debug JavaScript.

function HandleKeyDown() {
  debugger;
  // rest of your code here
}

If you're using IE, then in Tools - Advanced, you must make sure that "disable script debugging" is not checked, or it won't stop at your debug point.

If you use Visual Studio 2010, there's a neat JavaScript debugger built in :)


To me the best approach to troubleshooting is start taking out everything is not necessary to make i work. In this case, start deleting all the 3rd party scripts and extra code one at a time, while you try if it works or not every time you delete something. Sooner or later you will find what part of the code is causing this, then you can worry about how to fix it.

It would help if you could post a link to your code.


There are a couple of ways you could do it. Is there a javascript error?

If there is no error to indicate a line of code that's bad, then I would eliminate the thrid party scripts so that your script works as intended. Then, add in the scripts one at a time, continuously checking to see if your keydown still works.

Once you know which script is messing with the keydown functionality you can then start using comments and alerts to isolate the issue in that third party script.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜