Register now or log in to join your professional community.
On Running my web app, the browser keeps showing the following warning msg: "event.returnValue is deprecated. Please use the standard event.preventDefault() instead. " How can i remove it ? Note that i am using jquery-mobile-1.3.2 that calls the "e.returnValue " method which is not supported by jquery1.10 !? Any suggestions plz :S
It seems that you are using some old library version. Please use latest version and these warnings would be resolved automatically. Please make sure your other functionality doesn't affect by upgrading jQuery library.
السلام عليكم ورحمة الله وبركاته
It seems that the answerers didn't understand the problem well.
The problem is not in your code. It's in jQuery's. You shouldn't do anything. It's just a warning raised by the latest releases of chrome, and you may ignore it.
The problem is reported on jQuery's bug tracker here, and here. You need to just update your jQuery reference when new versions are released that possibly have this issue resolved.
event.returnValue is not a method, it's a property invented by Microsoft (internet explorer) I think, and was later adopted by other browsers. We used it in the old days to cancel events. If it's set to the boolean value false the event will be cancelled if it's cancellable.
Reference to the original answer:
http://stackoverflow.com/a//95970
Are you using Bootstrap?
The current version of Bootstrap (3.0.2) (w/ jQuery1.10.2 & Chrome) seem to generate this warning as well.
(it does so on Twitter too btw)
This is only a warning: your code still works, but probably won't work in the future as the method is deprecated.this has been already recognised and solved in jquery1.11
I guess its because you using older version of jquery... It hapens in the newer version of Chrome..
Salam Aya,
I am wondering which browser are you using?
can you post a sample of the code where you have the issue?
but based on your post, you are right event.returnvalue is not supported in the new version. here is a sample code to user the event.preventDefault():
$( "a" ).click(function( event ) { event.preventDefault(); $( "<div>" ) .append( "default " + event.type + " prevented" ) .appendTo( "#log" ); });
source of the sampel : http://api.jquery.com/event.preventDefault/
Just use event.preventDefault() instead unless you're expecting a return value from an event that will later be use. Or alternatively...
if ( event.preventDefault ) {
event.preventDefault();
} else {
event.returnValue = false;
}
or even shorter...
event.preventDefault ? event.preventDefault() : event.returnValue = false;