document.cookie = name + "=" + value + "; path=/; domain=yahoo.com";
这个cookies为什么我在cookies文件夹下找不到?
这个cookies为什么我在cookies文件夹下找不到?
解决方案 »
- 各位帮下忙,有关ztree,帮帮忙吧!!
- 高分求浏览器兼容性
- setTimeout的一个小问题,麻烦懂的人看下。有代码
- 下拉菜单鼠标移走没隐藏?
- 默认表格一行多高?文本域一行多高?
- firefox 在框架里面是不是不支持window.resizeTo(100, 900)
- 点击浏览器窗口右上角的“X”关闭窗口时,可不可以自动把父窗口也关了!
- 如何用js取出表格中的数据(急,在线等)。
- 树的问题
- 关于表单验证 无法验证用户名和密码是否相同 密码的长度和合法性也无法检查 如果去掉这些部分,其他能正常检查
- 如何一个值贬给网页内嵌入的html编辑器中。有读取出来的代码。
- 如何用JScript读网址后面类似?room=304&id=pp的参数
若设置了足够的有效期,在页面关闭时document.cookie的内容才会被写入文件
这是个VBscript函数,Cookie的有效期为1天;Sub SetCookie(strCookieName,strCookieValue)
Dim strTemp
strTemp=strCookieName & "=" & strCookieValue
strTemp=strTemp & ";expires=" & Weekday(Date,vbUseSystem) & ","
strTemp=strTemp & Day(Date)+1 & "-"
strTemp=strTemp & Month(Date) & "-"
strTemp=strTemp & Year(Date)
strTemp=strTemp & " 12:00:00 "
strTemp=strTemp & " GMT"
strTemp=strTemp & ";Path=/"
document.cookie=strTemp
End Sub
不过我不懂如何使用这个函数啊
strCookieName是变量名,strCookieValue 是你要赋给strCookieName的值;
赋值后用函数GetCookie就可以读出strCookieName的值了,下面是一个完整的例子:<HTML>
<HEAD>
<META name=VI60_defaultClientScript content=VBScript>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<SCRIPT ID=clientEventHandlersVBS LANGUAGE=vbscript>
<!--Sub SetCookie(strCookieName,strCookieValue)
On Error Resume Next
Dim strTemp
strTemp=strCookieName & "=" & strCookieValue
strTemp=strTemp & ";expires=" & Weekday(Date,vbUseSystem) & ","
strTemp=strTemp & Day(Date)+1 & "-"
strTemp=strTemp & Month(Date) & "-"
strTemp=strTemp & Year(Date)
strTemp=strTemp & " 12:00:00 "
strTemp=strTemp & " GMT"
strTemp=strTemp & ";Path=/"
document.cookie=strTemp
End Sub Function GetCookie(strCookieName)
On Error Resume Next
Dim strCookie
Dim intNamePos
Dim intNameLength
Dim intValueLength
Dim intNextSemicolon
Dim strTempCookie
strCookie=Document.Cookie
strTempCookie=strCookie
GetCookie=""
If strCookieName<>"" Then
intNamePos=InStr(1,strTempCookie,strCookieName,1)
intNameLength = Len(strCookieName)
Do While intNamePos>0
strTempCookie=Right(strTempCookie,Len(strTempCookie)-intNamePos+1)
If Mid(strTempCookie,intNameLength+1,1)<>"=" Then
Exit Function
Else
intNextSemicolon=InStr(strTempCookie,";")
If intNextSemicolon=0 Then
intNextSemicolon=Len(strTempCookie)+1
End If
If intNextSemicolon=(intNameLength+2) Then
Exit Function
Else
intValueLength=intNextSemicolon-intNameLength-2
GetCookie = Mid(strTempCookie, intNameLength + 2, intValueLength)
End If
End If
intNamePos=InStr(intNamePos+intNameLength,strTempCookie,strCookieName,1)
Loop
End If
End FunctionCall SetCookie("Name","阿江")
MsgBox GetCookie("Name")
-->
</SCRIPT>
</HEAD>
<BODY><P> </P></BODY>
</HTML>