// Example:// writeCookie("myCookie", "my name", 24);// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.function writeCookie(name, value, hours){  var expire = "";  if(hours != null)  {    expire = new Date((new Date()).getTime() + hours * 3600000);    expire = "; expires=" + expire.toGMTString();  }  document.cookie = name + "=" + escape(value) + expire;}// Example:// alert( readCookie("myCookie") );function readCookie(name){  var cookieValue = "";  var search = name + "=";  if(document.cookie.length > 0)  {     offset = document.cookie.indexOf(search);    if (offset != -1)    {       offset += search.length;      end = document.cookie.indexOf(";", offset);      if (end == -1) end = document.cookie.length;      cookieValue = unescape(document.cookie.substring(offset, end))    }  }  return cookieValue;}dreamweaver 8自带的。

解决方案 »

  1.   

    <script>
    //首先明确:cookie 的格式是 "cookie的名字=cookie的值; expires=cookie的结束时间; path=路径",
    function get_cookie(name) {
    var cookies = document.cookie.split(';');  //以分号为间隔返回数组
    for (var i = 0; i < cookies.length; i++) { //对每个信息操作 
    var cookie = cookies[i];
    var item = cookie.split('=');          //以等号分割
    if (trim(item[0]) == name) {           //如果cookie的名称为参数名称
    if (item[1] != null) {             //并且cookie的值不为空
    return unescape(item[1]);      //用unescape方法解码用 escape 方法进行了编码的cookie值
    } else {
    return "";
    }
    }
    }
    return null;
    }
    </script>
      

  2.   

    建议lz先把cookie的概念弄明白,再去做有关cookie的读取,设置,删除的开发~
    关于js的学习就要多看别人的代码啦,不会就查开发手册---js中文参考手册,DHTML
    手册
      

  3.   

    来javascript 版混半年 , js就差不多够用了
      

  4.   

    function getcookie(name) {
    var cookie_start = document.cookie.indexOf(name);
    var cookie_end = document.cookie.indexOf(";", cookie_start);
    return cookie_start == -1 ? '' : unescape(document.cookie.substring(cookie_start + name.length + 1, (cookie_end > cookie_start ? cookie_end : document.cookie.length)));
    }