ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

How to remove Jquery-1.10 warning msg "event.returnValue is deprecated."?

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

user-image
تم إضافة السؤال من قبل Aya Taleb , Senior Web Developer / Team Leader , Bayt.com / Talentera
تاريخ النشر: 2013/12/02
Muhammad Majid Saleem
من قبل Muhammad Majid Saleem , Senior PHP Developer / Project Manager , SwaamTech

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.

Ashraf Sabry
من قبل Ashraf Sabry , Freelancer developer , N/A

السلام عليكم ورحمة الله وبركاته

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

Taha Hanif
من قبل Taha Hanif , Software Developer , Design Your Site

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)

VIJAY PRASAD
من قبل VIJAY PRASAD

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

       

Mohideen Imran Khan
من قبل Mohideen Imran Khan , Senior Software Team Lead , ERIYADA SYSTEMS

I guess its because you using older version of jquery... It hapens in the newer version of Chrome..

zakaria laalami
من قبل zakaria laalami , Sr. Developer , Bloomin Brands International

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/

Clodelio Delfino
من قبل Clodelio Delfino , Managing Consultant , Startup Company

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;

المزيد من الأسئلة المماثلة