English 中文(简体)
谁能告诉我,这个县做了什么?
原标题:Can anyone please tell me what does this funciton do?
function w_cookie_wid(wid02) {
   if ( ! document.cookie) {
      document.cookie = "w_wid=1;path=/";
      if ( ! document.cookie) {
         var w_date = new Date();
         return (w_date.getSeconds() % 20 + 1);
      }
      else return 2 - 1;
   }
   var prefix = wid02 + "=";
   var begin = document.cookie.indexOf("; " + prefix);
   if (begin == - 1) {
      begin = document.cookie.indexOf(prefix);
      if (begin != 0) {
         return null;
      }
   }
   else {
      begin += 2;
   }
   var end = document.cookie.indexOf(";", begin);
   if (end == - 1) {
      end = document.cookie.length;
   }
   return unescape(document.cookie.substring(begin + prefix.length, end));
}
最佳回答

这项职能的目的是设法从网页库中检索一个厨师的价值。 如无 co,则该功能将试图确定<代码>w_wid=1;path=/和返回代码>1的违约值。 如果厨师得不到支持,1至20年的半衰期(按时间计算)价值将退还,不会 set。 如果安装了厨师,该功能将试图收回与名称参数相应的价值(wid02)。 如该名称没有找到,该功能将退回<代码>null,否则该数值将退还。

职能说明:

function w_cookie_wid(wid02) {
    //if there are no cookies for this page
    if (!document.cookie) {
        //set a cookie value associated with the root
        document.cookie = "w_wid=1;path=/";
        //if there still are no cookies (not supported/allowed)
        if (!document.cookie) {
            //make a new date representing the current time
            var w_date = new Date();
            //return a number between 1 and 20
            //based on the current time
            return (w_date.getSeconds() % 20 + 1);
        }
        //return 1 if the cookie set was successful
        else return 2 - 1;
    }
    //create the name portion for a cookie value
    var prefix = wid02 + "=";
    //check to see if that value is already set,
    //but not as the first item
    var begin = document.cookie.indexOf("; " + prefix);
    //if it isn t
    if (begin == -1) {
        //check to see if it is set as the first item
        begin = document.cookie.indexOf(prefix);
        //if it isn t set (at all)
        if (begin != 0) {
            //return a null value
            return null;
        }
    }
    //if it IS set somewhere
    else {
        //set begin to be the index of beginning
        //of the name/value pair
        begin += 2;
    }
    //get the index of the first semi-colon after
    //the beginning of the name/value
    var end = document.cookie.indexOf(";", begin);
    //if there isn t one
    if (end == -1) {
        //set the end index as the length of the cookie(s)
        end = document.cookie.length;
    }
    //return the cookie name/value pair string
    return unescape(document.cookie.substring(begin + prefix.length, end));
}

请不要再要求我们做事。

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签