I am trying to write a code that will display a pop-up message when a site is first visited and I want it to never display again if I already see it.. Here's my code, I hope someone could help me to prevent the pop up from appearing when I refresh the page although it shouldn't.
<SCRIPT LANGUAGE="JavaScript">
<!--
function GetCookie(cookie) {
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 "here";
i=document.cookie.indexOf(" ",i)+1;
if (i==0) break;
}
return null;
}
var visit=GetCookie("cookie");
if (visit==null){
alert("Your Message Goes here and you only get to see it once!");
var expire=new Date();
expire=new Date(expire.getTime()+7776000000);
document.cookie="cookie=here; expires="+expire;
}
// -->
</SCRIPT>