"The getPreventDefault() method should no longer be used. Instead, use defaultPrevented"

Asked

Viewed 2,773 times

5

In some browsers, such as Google Chrome, always when "move" in some element of the page, the following message appears:

Event.returnValue is deprecated. Please use the standard Event.preventDefault() Instead

Or else:

Use of getPreventDefault() is deprecated. Use defaultPrevented Instead

In my Firefox 39, appears:

The getPreventDefault() method should no longer be used. Instead, use defaultPrevented..

I am concerned about development whenever I see or hear the word Deprecated or Depreciated.

After all, what causes this message?

This refers to the event.preventDefault() which we generally use with the eventListener and/or with jQuery?

1 answer

6


As the Javascript language itself is evolving and new standards are adapted, some old features and methods are left behind. That is to say they are "deprecated" and that means that in the future they will no longer function.

It is always important to "keep the code", that is to update it to avoid errors in new browsers.

In case you are using a library just change the version to a newer one and test the code to see if everything works the same way, no errors.

If it is code itself is to find the method that replaces the old one and change.

In the case of getPreventDefault() This was an idea from Mozilla that was removed. The idea was to know if in a given event the .preventDefault() had been called. The standard method for doing this is event.defaultPrevented.

In the case of .returnValue This was an idea of Microsoft (Internet Explorer) and served to cancel/stop events. It was also abandoned by the current standard which is event.preventDefault();.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.