为什么我往cookie中保存一组数据,但是都不出来呢?
    document.cookie="userId=828";
  然后
  alert(document.cookie)显示为undefine??在线等,求解答,马上散分,谢谢。

解决方案 »

  1.   

    <script>
    document.cookie="userId=828;";
    alert(document.cookie)//没问题啊,直接输出上面的内容
    </script>除非你的浏览器禁用了cookie,没禁用加个path设置cookie路径试试document.cookie="userId=828;path=/";
      

  2.   

    感谢回复!
    我的仍然不行,我把代码粘出来<html>
    <head>
    <script language=javascript>
    document.cookie = "userID=828;path=/";
    alert(document.cookie); </script>
    </head>
    </html>弹出来的对话框上显示为空的,没有输出存进去的cookie的内容。
    另外我看浏览器的cookie应该是可用的,163的还有yahoo的cookie都能看见
      

  3.   

    用type="text/javascript"不要用 language=javascript
      

  4.   

    双击打开html文件的话,没有域,不能保存cookies
    你需要自己搭建一个服务器以http://xxx.xxx.com/xxx.html 的形式访问你的html文件
      

  5.   

    <script language=javascript>
    这个地方是要改为:
    <script language="text/javascript">