event.returnValue is deprecated. Please use the standard event.preventDefault() instead

event.returnValue is deprecated. Please use the standard event.preventDefault() instead

I have this script:

I receive the following error in my Google Chrome console:

event.returnValue is deprecated. Please use the standard event.preventDefault() instead.

I am using jQuery v1.10.2 and #changeResumeStatus is a .
What’s wrong with my script?

Solutions/Answers:

Solution 1:

This is only a warning: your code still works, but probably won’t work in the future as the method is deprecated. See the relevant source of Chromium and corresponding patch.

This has already been recognised and fixed in jQuery 1.11 (see here and here).

Solution 2:

Just for other’s reference, I just received this and found it was due to AngularJS. It’s for backwards compatibility:

if (!event.preventDefault) {
    event.preventDefault = function() {
        event.returnValue = false; //ie
    };
}

Solution 3:

If you using Bootstrap:

The current version of Bootstrap (3.0.2) (with jQuery 1.10.2 & Chrome) seems to generate this warning as well.

(It does so on Twitter too, BTW.)

Update

The current version of Bootstrap (3.1.0) no longer seems to generate this warning.

Related:  Why is jQuery so widely adopted versus other Javascript frameworks? [closed]

Solution 4:

That’s your jQuery API problem, not your script. There is not much to worry about.

Solution 5:

This is a warning related to the fact that most JavaScript frameworks (jQuery, Angular, YUI, Bootstrap…) offer backward support for old-nasty-most-hated Internet Explorer starting from IE8 down to IE6 :/

One day that backward compatibility support will be dropped (for IE8/7/6 since IE9 deals with it), and you will no more see this warning (and other IEish bugs)..

It’s a question of time (now IE8 has 10% worldwide share, once it reaches 1% it is DEAD), meanwhile, just ignore the warning and stay zen 🙂

Solution 6:

I found that using the latest version will fix this problem:
http://code.jquery.com/jquery-git.js