Home > Web Front-end > JS Tutorial > JavaScript code that pops up once every 24 hours (using cookies)_advertising code

JavaScript code that pops up once every 24 hours (using cookies)_advertising code

WBOY
Release: 2016-05-16 18:47:09
Original
1439 people have browsed it
Copy code The code is as follows:

function jb51tuitan(){
if (getCookie('jb51popped' )==''){
//Code or some operations to be executed
setCookie("jb51popped","ok"); //Writing cookies indicates that it has been executed.
alert("ok");
}
}
jb51tuitan()
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))
                                                                                                                                                                                   . Just put it in the judgment statement.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template