部分script cookies 操作
来源:互联网 发布:网络软营销理论强调 编辑:程序博客网 时间:2024/05/21 22:48
/*------------------------------------------------------------
Author: TNT!Bang
Company: Infinity Technologies
Url: http://www.infinitytechnologies.com.au
Email: wlinfinity@yahoo.com.cn
Date: 2006-8-8
Description: Javascript -> Cookie handle
------------------------------------------------------------*/
/*
Description: Write key to cookie
Parameter: name string, cookie name
value string, cookie value
*/
var expiryHours = 24;
function SetCookie(name, value, hours){
if (String(name) == "undefined" || name == null || name == "" ) return;
var expire = "";
if(hours != null) {
expire = new Date((new Date()).getTime() + hours * 3600000);
expire = "; expires=" + expire.toGMTString();
}
document.cookie = name + "=" + escape(value) + expire;
}
function RemoveCookie(name) {
SetCookie( name, '', -1 );
}
function ClearCookie() {
var name, a = document.cookie.split( ";" );
for(var i=0; i<a.length; i++ ) {
name = a[i].split( "=" );
if (name.length>0) RemoveCookie(name[0]);
}
}
function Combine(){
var args = Combine.arguments;
var result = "";
for(var i=0; i<args.length; i++ ){
if (String(args[i])!= 'undefined' && args[i] != null && args[i]!= "" ) {
if (result != "" ) result += ",";
result += args[i];
}
}
return result;
}
function ExistsCookieValue( name, value ) {
var v = GetCookie( name );
if (String(v) == "undefined" || v == null || v == "" ) return false;
var a = v.split( ',' );
for( var i= 0; i<a.length; i++ ) {
if ( a[i] == value) return true;
}
return false;
}
function ExistsCookieKey( key ) {
if (String(key) == "undefined" || key == null || key == "" ) return false;
var name, a = document.cookie.split( ';' );
for( var i= 0; i<a.length; i++ ) {
name = a[i].split( "=" );
if ( name.length>0 && name[0]==key) return true;
}
return false;
}
function AppendCookie(name, value, hours) {
if (ExistsCookieValue(name,value)) return;
var v = GetCookie( name );
SetCookie( name, Combine( v, value ), hours );
}
function GetCookie(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;
}
- 部分script cookies 操作
- Cookies操作
- Cookies操作
- PHP用户指南-cookies部分
- Javascript 操作Cookies
- Javascript 操作Cookies
- JS操作COOKIES函数
- js操作cookies
- js操作cookies
- javascript 操作 cookies
- js 操作cookies
- javascript cookies操作
- js操作cookies
- javascript操作Cookies
- javascript 操作cookies
- 对 cookies 操作!
- javascript 操作cookies
- JS操作Cookies
- C#设计模式(3)
- 安全编程详解
- C#设计模式(4)-Simple Factory Pattern
- C#设计模式(5)-Factory Method Pattern
- 艺术网站收藏
- 部分script cookies 操作
- 为SmartMovie制作完美字幕
- C#设计模式(6)-Abstract Factory Pattern
- C#设计模式(7)-Singleton Pattern
- Perlis教授折磨脑子的家庭作业
- C#设计模式(8)-Builder Pattern
- 创建动态数据输入用户界面
- 测试
- C#设计模式(9)-Prototype Pattern