setcookie函数在计算机上清除历史记录后返回空白警报

时间:2017-03-12 17:29:34

标签: javascript cookies

我正在处理一些cookie函数并使我的setCookie函数正常工作,并将其设置为在单击Set Cookie按钮时显示。当我试图让我的获取饼干功能正常工作时,我在计算机上清除了我的历史 - 现在我得到的是一个空白警报 - 有人可以帮忙吗?

 function setCookie(cname, cvalue, exdays) {
 var d = new Date();
 d.setTime(d.getTime() + (exdays*24*60*60*1000));
 var expires = "expires="+ d.toUTCString();
 document.cookie = cname + "=" + encodeURIComponent(cvalue) + ";" +      expires + ";path=/";

  alert("cookie is working");

}

 function getCookieTable() {


 alert("test2");
  var table =document.getElementById('tg-LTO9U');
  var rowLength = table.rows.length;
  var columnLength = table.rows[0].cells.length;
  var Cookiedata = '';

 alert("test3");
 for(var i=0;i<rowLength;i++){

   for (var j=0; j<table.rows[i].cells.length; j++) {
   Cookiedata += table.rows[i].cells[j].innerHTML + ",";
}

}

 Cookiedata = rowLength + "," + columnLength + "," +              Cookiedata.substring(0, Cookiedata.length);
setCookie("myCookie", Cookiedata, 7);

  alert(document.cookie);

}

0 个答案:

没有答案