How to make a site look slightly different to returning visitors...

mancar487

Elite Member
Joined
Apr 12, 2012
Messages
2,218
Reaction score
2,817
Hello,

I'm posting a question that may also be of use to others.
Basically I want to add a 'magic buy button' (timed button - it appears after a specific time interval) to my website. I have found the code to add the button, however, my problem is: I want this button to appear right from the start to returning visitors. How do I do this?

I have found this piece of code, but I do not know how to implement it for the magic button:

Code:
setcookie("FirstVisit", '1');

Code:
function DisplayWelcomeMessage()
{
    if (isset($_COOKIE['FirstVisit']) && $_COOKIE['FirstVisit'] == 1)
    {
         // Display a welcome message


         // Update the cookie so that they don't get this message again
         setCookie("FirstVisit", "0");
    }
    else
    {
        // Do something different for people who have visited before
    }
}


P.s the code I am using for the magic button is:

in header:

Code:
<script type="text/javascript">
$secondsdelay = 90;
function unhide(divID) {
var item = document.getElementById(divID);
if (item) {
item.className=(item.className=='hidden')?'unhidde n':'hidden';
}
}
$delay = $secondsdelay*1000;
window.setTimeout("unhide('links')",$delay);
//--></script>
<STYLE TYPE="text/css">
.hidden { visibility: hidden; }
.unhidden { visibility: visible; } 
</STYLE>

before the magic button:

Code:
  <div id="links" class="hidden">
 
Shoot me a PM with your skype, i'll help you out, for free of course.
 
Thank you so such for solving this for free, you're an amazing programmer and a great guy!
P.S. you can post the script here, it may help others. Thanks a million :)
 
No problem man, glad i could help you out.

And yea, in case someone else needs this script here it is:

Code:
<html>
<head>


<title>Test</title>


<script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>


       <script type="text/javascript">
	   
	   function getCookie(name) {
		var dc = document.cookie;
		var prefix = name + "=";
		var begin = dc.indexOf("; " + prefix);
		if (begin == -1) {
			begin = dc.indexOf(prefix);
			if (begin != 0) return null;
		}
		else
		{
			begin += 2;
			var end = document.cookie.indexOf(";", begin);
			if (end == -1) {
			end = dc.length;
			}
		}
		return unescape(dc.substring(begin + prefix.length, end));
	} 


	function checkit() {
		var myCookie = getCookie("FirstTime");


		if (myCookie == null) {
			// do cookie doesn't exist stuff;
			setTimeout(function() { document.getElementById('links').style.display ='block'}, 5000)
			document.cookie = 'FirstTime=test; expires=Fri, 3 Aug 2050 20:47:11 UTC; path=/';
		}
		else {
			// do cookie exists stuff
			setTimeout(function() { document.getElementById('links').style.display ='block'}, 1)
		
		}
	}
	   
		</script>


</head>


<body onload="checkit();">


<div id="links" style="display: none;">
BUTTON HERE
</div>
 
Back
Top