This is a Web page special effects code A:
function Setcookie (name,value,days) {
var exp=new date ();
Exp.settime (Exp.gettime () + days*24*60*60*1000);
var arr=document.cookie.match (new RegExp (^|) +name+ "= ([^;] *)(;|$)"));
document.cookie=name+ "=" +escape (value) + "; expires=" +exp.togmtstring ();
}
function GetCookie (name) {
var arr=document.cookie.match (new RegExp (^|) +name+ "= ([^;] *)(;|$)"));
if (arr!=null) {
Return unescape (arr[2]);
return null;
}
}
function Delcookie (name) {
var exp=new date ();
Exp.settime (Exp.gettime ()-1);
var cval=getcookie (name);
if (cval!=null) {
document.cookie=name+ "=" +cval+ "; expires=" +exp.togmtstring ();
}
}
The above code is the function of reading and writing cookies, which you do not need to understand, as long as you know how to use on the line
MJJ look at the following page special effects code, the code saved as pacth.js in the same Web page call, note that first call JS code A, and then call JS Code b
<script src= "Cookies.js" ></script><script src= "Patch.js" ></script>
Attention to the path problem, this is not much to say
This is JS code b
function out () {
if (GetCookie ("Out")!= "yes") {
Setcookie ("Out", "yes", 1);d ocument.write (' Place your JS code here-Callout 1 ');
}
}
Out ();
The code here is to call the function in the cookie to determine if the cookie named out already exists, and if not, set the cookie to Yes
And then run your JS code.
At this point, if you refresh the page, the second named out cookies already exist, you will not run the code labeled 1
Add:
What if I want to set up a window and have more code to set the time?
Then rename the function out () and set up a function to control the time.
I'm afraid I'm not sure.
Let me give you an example
function out1 () {
if (GetCookie ("out1")!= "yes") {
Setcookie ("Out1", "yes", 1);d ocument.write (' Place your JS code 1-Callout 1 ');
}
}
OUT1 ();
[Code]function Out2 () {
if (GetCookie ("Out2")!= "yes") {
Setcookie ("Out2", "yes", 1);d ocument.write (' Place your JS code 2-Callout 1 ');
}
}[
Out2 ();
/code] by analogy