31
SMF For Free Codes and Support / [Code] Welcome Cookie
« on: June 23, 2009, 08:27:43 am »
I know the pop up at when you go to the page are kinda annoying but some people like em so here is a welcome cookie
Headers:
If it's your first visit to the forum then a text box will pop up and say "Welcome visitor please type your name and hit enter" once that's done what ever name you type in when you go back to that forum it will say Hello and Welcome back, USERNAME THAT YOU TYPED IN i hope some one finds this useful does take a while to make...
Headers:
Code: [Select]
<html>
<head>
<script type="text/javascript">
//Code Made By:JayB
function getCookie(c_name)
//..http://thepogohideout.mysmf.com
{
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name + "=");
if (c_start!=-1)
{
c_start=c_start + c_name.length+1 ;
c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1) c_end=document.cookie.length
return unescape(document.cookie.substring(c_start,c_end));
}
}
return ""
}
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : "; expires="+exdate.toGMTString());
}
function checkCookie()
{
username=getCookie('username');
if (username!=null && username!="")
{
alert('Hello and Welcome back, '+username+'!');
}
else
{
username=prompt('Welcome visitor please type your name and hit enter.',"");
if (username!=null && username!="")
{
setCookie('username',username,365);
}
}
}
</script>
</head>
<body onLoad="checkCookie()">
</body>
</html>
If it's your first visit to the forum then a text box will pop up and say "Welcome visitor please type your name and hit enter" once that's done what ever name you type in when you go back to that forum it will say Hello and Welcome back, USERNAME THAT YOU TYPED IN i hope some one finds this useful does take a while to make...