Ricky158
11-16-2002, 11:18 PM
i have this code so far:
<head>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function GetCookie (name) {
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;
}
function SetCookie (name, value) {
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;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
var expDays = 30;
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function amt(){
var count = GetCookie('count')
if(count == null) {
SetCookie('count','1')
return 1
}
else {
var newcount = parseInt(count) + 1;
DeleteCookie('count')
SetCookie('count',newcount,exp)
return count
}
}
function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
// End -->
</SCRIPT>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
document.write("You have visited this page<font color=gold>" + amt() + "</font> times.")
// End -->
</SCRIPT>
i need to know (if possible, i believe it is) how to redirect someone to "URL2" if they have visited the page (using the code above as a base) let's say... 25 times. so if they were to visit for the 25th time, they would automatically be redirected to URL2. and after the 25th time at URL2, they would be redirected to URL1. it seems silly and unnecessary, but this would help me keep bandwidth to a minimum to redirect people, or at least i hope so.
(side note) URL2 is identical down to every picture, text size/color, and content, with URL1. so they would notice absolutely nothing different. both URLs have a series of pages in it. it's basically an entire web site duplicated.
also, since this is a tiny problem i'm having and it shouldnt require an entirely new thread just for itself, what is the script so that someone clicks a link and then it refreshes the page?
and one more question. is there a way to put a variable on URL1 so i could just do document.write on URL2 so i dont have to update both pages with the same changes?
thanks. an answer to any of my problems is appreciated.
<head>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function GetCookie (name) {
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;
}
function SetCookie (name, value) {
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;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
var expDays = 30;
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function amt(){
var count = GetCookie('count')
if(count == null) {
SetCookie('count','1')
return 1
}
else {
var newcount = parseInt(count) + 1;
DeleteCookie('count')
SetCookie('count',newcount,exp)
return count
}
}
function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
// End -->
</SCRIPT>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
document.write("You have visited this page<font color=gold>" + amt() + "</font> times.")
// End -->
</SCRIPT>
i need to know (if possible, i believe it is) how to redirect someone to "URL2" if they have visited the page (using the code above as a base) let's say... 25 times. so if they were to visit for the 25th time, they would automatically be redirected to URL2. and after the 25th time at URL2, they would be redirected to URL1. it seems silly and unnecessary, but this would help me keep bandwidth to a minimum to redirect people, or at least i hope so.
(side note) URL2 is identical down to every picture, text size/color, and content, with URL1. so they would notice absolutely nothing different. both URLs have a series of pages in it. it's basically an entire web site duplicated.
also, since this is a tiny problem i'm having and it shouldnt require an entirely new thread just for itself, what is the script so that someone clicks a link and then it refreshes the page?
and one more question. is there a way to put a variable on URL1 so i could just do document.write on URL2 so i dont have to update both pages with the same changes?
thanks. an answer to any of my problems is appreciated.