dlg0351
01-28-2005, 08:59 PM
Can someone help me with a cookie? I have a flash intro page that I only want to be displayed the first time that the page is viewed, other wise I want the visitor to be redirected to a new page or the page that would come after the flash intro.
I have seen other code on here that does something similar, such as the code below:
<html>
<head>
<title></title>
<SCRIPT LANGUAGE="JavaScript">
<!--
cookie_name = "Cookie1";
function doCookie()
{
gettimes();
if(document.cookie)
{
index = document.cookie.indexOf(cookie_name);
}
else
{
index = -1;
}
var expires = "Monday, 04-Apr-2010 05:00:00 GMT"
if (index == -1)
{
document.cookie=cookie_name+"=1; expires=" + expires;
}
else
{
countbegin = (document.cookie.indexOf("=", index) + 1);
countend = document.cookie.indexOf(";", index);
if (countend == -1)
{
countend = document.cookie.length;
}
count = eval(document.cookie.substring(countbegin, countend)) + 1;
document.cookie=cookie_name+"="+count+"; expires=" + expires;
}
}
function gettimes()
{
if(document.cookie)
{
index = document.cookie.indexOf(cookie_name);
if (index != -1)
{
countbegin = (document.cookie.indexOf("=", index) + 1);
countend = document.cookie.indexOf(";", index);
if (countend == -1)
{
countend = document.cookie.length;
}
count = document.cookie.substring(countbegin, countend);
if (count >= 1)
{
redirect();
return null;
}
else
{
return null;
}
}
}
}
function redirect()
{
window.location="index2.html";
}
//-->
</SCRIPT>
</head>
<body onLoad="doCookie()">
This is the body of the page.
</body>
</html>
But this code still displays the flash page and then quickly redirects you to the second page. I do not want any of the original or flash page to be displayed at all, I just want you to be forwarded.
I was thinking that this would work but it does not display what I want in the body of the page:
<html>
<head>
<title></title>
<SCRIPT LANGUAGE="JavaScript">
<!--
cookie_name = "Cookie1";
function doCookie()
{
gettimes();
if(document.cookie)
{
index = document.cookie.indexOf(cookie_name);
}
else
{
index = -1;
}
var expires = "Monday, 04-Apr-2010 05:00:00 GMT"
if (index == -1)
{
document.cookie=cookie_name+"=1; expires=" + expires;
}
else
{
countbegin = (document.cookie.indexOf("=", index) + 1);
countend = document.cookie.indexOf(";", index);
if (countend == -1)
{
countend = document.cookie.length;
}
count = eval(document.cookie.substring(countbegin, countend)) + 1;
document.cookie=cookie_name+"="+count+"; expires=" + expires;
}
}
function gettimes()
{
if(document.cookie)
{
index = document.cookie.indexOf(cookie_name);
if (index != -1)
{
countbegin = (document.cookie.indexOf("=", index) + 1);
countend = document.cookie.indexOf(";", index);
if (countend == -1)
{
countend = document.cookie.length;
}
count = document.cookie.substring(countbegin, countend);
if (count >= 1)
{
redirect();
return null;
}
else
{
showPage();
return null;
}
}
}
}
function redirect()
{
window.location="index2.html";
}
function showPage()
{
document.write("This is the body of the page.");
}
//-->
</SCRIPT>
</head>
<body onLoad="doCookie()">
</body>
</html>
Any help is greatly appreciated!
Thanks.
-Dave
I have seen other code on here that does something similar, such as the code below:
<html>
<head>
<title></title>
<SCRIPT LANGUAGE="JavaScript">
<!--
cookie_name = "Cookie1";
function doCookie()
{
gettimes();
if(document.cookie)
{
index = document.cookie.indexOf(cookie_name);
}
else
{
index = -1;
}
var expires = "Monday, 04-Apr-2010 05:00:00 GMT"
if (index == -1)
{
document.cookie=cookie_name+"=1; expires=" + expires;
}
else
{
countbegin = (document.cookie.indexOf("=", index) + 1);
countend = document.cookie.indexOf(";", index);
if (countend == -1)
{
countend = document.cookie.length;
}
count = eval(document.cookie.substring(countbegin, countend)) + 1;
document.cookie=cookie_name+"="+count+"; expires=" + expires;
}
}
function gettimes()
{
if(document.cookie)
{
index = document.cookie.indexOf(cookie_name);
if (index != -1)
{
countbegin = (document.cookie.indexOf("=", index) + 1);
countend = document.cookie.indexOf(";", index);
if (countend == -1)
{
countend = document.cookie.length;
}
count = document.cookie.substring(countbegin, countend);
if (count >= 1)
{
redirect();
return null;
}
else
{
return null;
}
}
}
}
function redirect()
{
window.location="index2.html";
}
//-->
</SCRIPT>
</head>
<body onLoad="doCookie()">
This is the body of the page.
</body>
</html>
But this code still displays the flash page and then quickly redirects you to the second page. I do not want any of the original or flash page to be displayed at all, I just want you to be forwarded.
I was thinking that this would work but it does not display what I want in the body of the page:
<html>
<head>
<title></title>
<SCRIPT LANGUAGE="JavaScript">
<!--
cookie_name = "Cookie1";
function doCookie()
{
gettimes();
if(document.cookie)
{
index = document.cookie.indexOf(cookie_name);
}
else
{
index = -1;
}
var expires = "Monday, 04-Apr-2010 05:00:00 GMT"
if (index == -1)
{
document.cookie=cookie_name+"=1; expires=" + expires;
}
else
{
countbegin = (document.cookie.indexOf("=", index) + 1);
countend = document.cookie.indexOf(";", index);
if (countend == -1)
{
countend = document.cookie.length;
}
count = eval(document.cookie.substring(countbegin, countend)) + 1;
document.cookie=cookie_name+"="+count+"; expires=" + expires;
}
}
function gettimes()
{
if(document.cookie)
{
index = document.cookie.indexOf(cookie_name);
if (index != -1)
{
countbegin = (document.cookie.indexOf("=", index) + 1);
countend = document.cookie.indexOf(";", index);
if (countend == -1)
{
countend = document.cookie.length;
}
count = document.cookie.substring(countbegin, countend);
if (count >= 1)
{
redirect();
return null;
}
else
{
showPage();
return null;
}
}
}
}
function redirect()
{
window.location="index2.html";
}
function showPage()
{
document.write("This is the body of the page.");
}
//-->
</SCRIPT>
</head>
<body onLoad="doCookie()">
</body>
</html>
Any help is greatly appreciated!
Thanks.
-Dave