热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

javascript24小时弹出一次的代码(利用cookies)分享

代码如下:functionphpstudytuitan(){if(getCookie('phpstudypopped')''){要执行的代码

代码如下:
function phpstudytuitan(){
if (getCOOKIE(‘phpstudypopped’)==”){
//要执行的代码或一些操作
setCOOKIE(“phpstudypopped”,”ok”); //写入COOKIEs表示已经执行过了。
alert(“ok”);
}
}
phpstudytuitan()
function setCOOKIE(name, value)
{
var argv = setCOOKIE.arguments;
var argc = setCOOKIE.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
if(expires!=null)
{
var LargeExpDate = new Date ();
LargeExpDate.setTime(LargeExpDate.getTime() + (expires*1000*3600*24));
}
document.COOKIE = name + “=” + escape (value)+((expires == null) ? “” : (“; expires=” +LargeExpDate.toGMTString()));
}

function getCOOKIE(Name)
{
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
return unescape(document.COOKIE.substring(offset, end))
}
else return “”
}
}

把想要输出的内容,放到phpstudytuitan()函数里面的判断语句里面即可。

—-想了解更多的linux相关异常处理怎么解决关注<编程笔记>




推荐阅读
author-avatar
手机用户2602915671
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有