jQuery警告:不推荐使用event.returnValue。请改用标准的event.preventDefault() [英] jQuery warning: event.returnValue is deprecated. Please use the standard event.preventDefault() instead

查看:82
本文介绍了jQuery警告:不推荐使用event.returnValue。请改用标准的event.preventDefault()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是sindhuri,我在Google Chrome控制台中收到以下警告:
event.returnValue已弃用。请改用标准的event.preventDefault()。我正在使用的
jquery1.9.1版本。

this is sindhuri,I receive the following warning in my Google Chrome console: event.returnValue is deprecated. Please use the standard event.preventDefault() instead. jquery1.9.1 version i am using.

<script>
window.jQuery(document).ready(function () {
    window.jQuery('#hideshow').click(function () {
        window.jQuery('#message').toggle(function () {
            window.jQuery('#hideshow').text('Show');
            window.jQuery('#message').hide();
            alert("message hide succeesfully");
        }),
        function () {
            window.jQuery('#hideshow').text('Hide');
            window.jQuery('#message').show();

            alert("message show succeesfully");
        }
    });
});
</script> <a href="#" id="hideshow">Hide</a>



BeforeUnloadEvent具有returnValue属性。将returnValue设置为事件处理程序中的非空字符串会导致用户代理应该要求用户确认他们是否要卸载该文档。这相当于在EventHandler中返回一个非空字符串

BeforeUnloadEvent has a returnValue attribute. Setting returnValue to a non-empty string in an event handler causes the user agent should ask the user to confirm that they wish to unload the document. This is equivalent to returning a non-empty string in the EventHandler

推荐答案

这不是一个错误......

this is not a bug...

只需使用即将推出的最新版本(1.11),你会没事的

just use the latest version thats going to come out soon (1.11) and you'll be fine

这有一个 jquery.com开票


该错误已修复为1.11 / 2.1。重复的错误
票#14282解释了这一点。它还解释了旧版本的
jQuery将永远发出此警告。

The bug is fixed in what will become 1.11/2.1. The duplicate bug ticket #14282 explains this. It also explains that older versions of jQuery will give this warning eternally.

这篇关于jQuery警告:不推荐使用event.returnValue。请改用标准的event.preventDefault()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆