Javascript- cookie?
with the attached code I am unable to retrieve my cookie, did I leave something out of my code. I am trying to write the code without using a lot of functions to set,check & get.
sorry,
if (document.cookie.length>0)
{
s=document.cookie.indexOf("name=")
if (s != -1)
{
s2 = s + 5
e=document.cookie.indexOf(";",s2)
if (e==-1)
e=document.cookie.length
name = document.cookie.substring
(s2,e))
}
}
<html>
<head>
<title> create cookie </title>
</head>
<body>
<script type="text/javascript">
var document.cookie=alert("Please enter your name","");
document.write("<br/> You entered " name+ ";
I am trying ti write a cookie, also to check if a cookie has visited before, if not, to ask for name, & the next time to greet with name.
|