<script type="text/javascript">function getCookie(c_name)
{
debugger
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=") //这代码什么意思
  if (c_start!=-1)                                这代码什么意思
    { 
    c_start=c_start + c_name.length+1             这代码什么意思
    c_end=document.cookie.indexOf(";",c_start)      这代码什么意思
    if (c_end==-1) c_end=document.cookie.length      这代码什么意思
    return unescape(document.cookie.substring(c_start,c_end))        这代码什么意思
    } 
  }
return ""
}function setCookie(c_name,value,expiredays)
{
debugger
var exdate=new Date() 
exdate.setDate(exdate.getDate()+expiredays)         这代码什么意思document.cookie=c_name+ "=" +escape(value)+        这代码什么意思 特别是这个"=" ? : 这些
((expiredays==null) ? "" : ";expires="+exdate.toGMTString())      这代码什么意思
}function checkCookie()
{
debugger
username=getCookie('username')
if (username!=null && username!="")
  {alert('Welcome again '+username+'!')}
else 
  {
  username=prompt('Please enter your name:',"")  if (username!=null && username!="")
    {
    setCookie('username',username,365)
    }
  }
}
</script>
<input type="submit" onload=checkcookie()/>不胜感激  谢谢

解决方案 »

  1.   

    这些都是js的基本语法啊。你找本js参考手册看看就明白了 
    indexOf 方法http://www.google.com.hk/search?q=javascript+indexOf&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:zh-CN:official&client=firefox-a
      

  2.   

    <script type="text/javascript">function getCookie(c_name)
    {
    debugger
    if (document.cookie.length>0)
      {
      c_start=document.cookie.indexOf(c_name + "=") //这代码是说字符串格式的cookie里形如“id=121;”i的下表位置
      if (c_start!=-1) 这代码是说cookie里包含形如“name=”
      { 
      c_start=c_start + c_name.length+1 // 这代码是说形如“id=121;name=sds;”,";"的位置
      c_end=document.cookie.indexOf(";",c_start) //这代码";"的位置,若不存在“;”则返回-1
      if (c_end==-1) c_end=document.cookie.length //这代码是说没找到则结束下标到末尾
      return unescape(document.cookie.substring(c_start,c_end)) //这代码获得cookie完整字符串,形如“name=sdss”
      } 
      }
    return ""
    }function setCookie(c_name,value,expiredays)
    {
    debugger
    var exdate=new Date() 
    exdate.setDate(exdate.getDate()+expiredays) 这代码设置失效日期document.cookie=c_name+ "=" +escape(value)+ 这代码escape格式编码处理意思 特别是这个"=" ? : 这些
    ((expiredays==null) ? "" : ";expires="+exdate.toGMTString()) 这代码过期时间规定为GMT格式
    }function checkCookie()
    {
    debugger
    username=getCookie('username')
    if (username!=null && username!="")
      {alert('Welcome again '+username+'!')}
    else 
      {
      username=prompt('Please enter your name:',"")  if (username!=null && username!="")
      {
      setCookie('username',username,365)
      }
      }
    }
    </script>
    <input type="submit" onload=checkcookie()/>