JQuery Cookie不能使用chrome [英] JQuery Cookie not working on chrome

查看:120
本文介绍了JQuery Cookie不能使用chrome的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行此代码,

<html>
    <head>
        <title>D</title>
        <script type="text/javascript" src="jQuery.js"></script>
        <script type="text/javascript" src="Cookie.js"></script>
        <script type="text/javascript">
            $(document).ready( function() {
                $.cookie("d", "1") ;
            }) ;
        </script>
    </head>

    <body>
            <script type="text/javascript">
                alert( $.cookie("d") ) ;
            </script>
    </body>
</html>

在Firefox,IE上显示为1,但在Chrome中为null。任何想法为什么?我使用的是来自 http://plugins.jquery.com的最新jQuery和Cookie插件/files/jquery.cookie.js.txt

It's showing '1' on Firefox, IE, but 'null' in chrome. Any idea why? I'm using latest jQuery and cookie plugin from http://plugins.jquery.com/files/jquery.cookie.js.txt

推荐答案

Chrome不支持本地用户的Cookie,除非您开始它与--enable-file-cookies标志。您可以访问此处查看有关该讨论的讨论

Chrome doesn't support cookies for locals unless you start it with the --enable-file-cookies flag. You can read a discussion about it at here

*如果您直接使用本地IP地址(127.0.0.1),Chrome会支持Cookie。所以在localhost的情况下,这可能是一个更容易的解决方法。

*Chrome does support cookies if you use the local IP address (127.0.0.1) directly. so in the localhost case, that could be an easier workaround.

这篇关于JQuery Cookie不能使用chrome的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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