<a href="aaa.html" onclick="return checkCookie(this)">test</a><SCRIPT>
function checkCookie(xx)
{
if(GetCookie("myname")==null or if(GetCookie("myname")=="")
{
return (confirm("要打开嘛?"))
}}
function GetCookie(sName)
{
// cookies are separated by semicolons
var aCookie = document.cookie.split("; ");
for (var i=0; i < aCookie.length; i++)
{
// a name/value pair (a crumb) is separated by an equal sign
var aCrumb = aCookie[i].split("=");
if (sName == aCrumb[0])
return unescape(aCrumb[1]);
} // a cookie with the requested name does not exist
return null;
}
</SCRIPT>
function checkCookie(xx)
{
if(GetCookie("myname")==null or if(GetCookie("myname")=="")
{
return (confirm("要打开嘛?"))
}}
function GetCookie(sName)
{
// cookies are separated by semicolons
var aCookie = document.cookie.split("; ");
for (var i=0; i < aCookie.length; i++)
{
// a name/value pair (a crumb) is separated by an equal sign
var aCrumb = aCookie[i].split("=");
if (sName == aCrumb[0])
return unescape(aCrumb[1]);
} // a cookie with the requested name does not exist
return null;
}
</SCRIPT>
解决方案 »
- JS变量里如何赋值JS代码呢?
- 如何避免JS事件被重复触发
- 1st JavaScript Editor Pro 中,调试时,funcion中的的语句不能识别?
- 关于mce_的问题
- (1)showModelessDialog如何在子窗口设置父窗口的超链接的onclick事件?子窗口指定父窗口的超链接的onclick事件,关闭子窗口后,点击父窗
- 请教表格动态添加行的问题
- 请帮帮忙!在线等
- e.options.add(new Option(a[i], a[i])
- 简单问题,如何打开定制窗口?
- CSDN的管理员都放假了吗?FAQ里出了那末明显的一个问题居然一直没人管!!!
- 如何知道某个对象方法的适用版本?
- 请教一个麻烦的问题
function checkCookie()
{
if(GetCookie("myname")==null || GetCookie("myname")=="")
{
return (confirm("要打开嘛?"))
}}
function GetCookie(sName)
{
// cookies are separated by semicolons
var aCookie = document.cookie.split("; ");
for (var i=0; i < aCookie.length; i++)
{
// a name/value pair (a crumb) is separated by an equal sign
var aCrumb = aCookie[i].split("=");
if (sName == aCrumb[0])
return unescape(aCrumb[1]);
} // a cookie with the requested name does not exist
return null;
}
</SCRIPT>
//获得Cookie解码后的值
{
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function SetCookie(name, value)
//设定Cookie值
{
var expdate = new Date();
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
if(expires!=null) expdate.setTime(expdate.getTime() + ( expires * 1000 ));
document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires="+ expdate.toGMTString()))
+((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain))
+((secure == true) ? "; secure" : "");
}function DelCookie(name)
//删除Cookie
{
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString();
}function GetCookie(name)
//获得Cookie的原始值
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return GetCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}