Firebug JS warning to jQuery 1.4.2 “The 'charCode' property of a keyup event should not be used. The value is meaningless.” To ignore it?

☆樱花仙子☆ 提交于 2019-11-29 14:46:42
gnarf

The jQuery code itself normalizes every event in jQuery.event.fix

// props includes 'charCode' - this will access it
for ( var i = this.props.length, prop; i; ) {
  prop = this.props[ --i ];
  event[ prop ] = originalEvent[ prop ];
}

// also, later in the same function

// Add which for key events
if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) {
  event.which = event.charCode || event.keyCode;
}

One of these lines of code is going to access charCode, which in turn creates your warning... You don't even need to do anything in your event handler (illustrated on jsfiddle)...

The "solution" I usually end up using is just running without JS warnings (errors still show up)

You can safely ignore this message (assuming you aren't using charCode, and are indeed using which)

This is a very common error message that comes out of mozilla code. The message comes out for every keystroke and it can lead to performance problems if you have the error console open. I've complained to mozilla about this and similar messages to no effect. jjb

try to change charCode -> XcharCode in source jquery-1.X.X.js and everything works OK

in the lastest version 1.4.4 there are "4" ocurrences...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!