Hi... i hope you can help me... thanks in advanced...
I have to sites, one in english and the other one in spanish, I want to set up a javascript code that when a user hits an achor text on mainsite.com links the user to secondsite.com and at the same time create a cookie that every time that that user types mainsite.com the cookie redirects the user to secondsite.com
I have this code... the problem is...
<script type="text/javascript">
<!--
/* Copyright
http://www.perlscriptsjavascripts.com
Free and commercial Perl and JavaScripts */
function SetCookie(Name, Value){
document.cookie = Name + "="+escape(Value)+";expires="+ged(1);
}
// page to go to if cookie exists
var go_to = "http://www.enhibarrio.ning.com";
//name for this page's cookie. Make sure each page has a differnt one
var thisCookie="clicked1";
// number of days cookie lives for
num_days = 1;
function ged(noDays) {
var today = new Date();
var expr = new Date(today.getTime() + noDays*24*60*60*1000);
return expr.toGMTString();
}
function readCookie(cookieName){
var start = document.cookie.indexOf(cookieName);
var cookieval=unescape(document.cookie.substring((star t+cookieName.length+1), document.cookie.indexOf(";", start)));
if(start>=0) { //then the cookie existed
window.location=go_to;
} else {
//do nothing
}
}
readCookie(thisCookie);
// -->
</script>
<span onclick="SetCookie(thisCookie, 'yes')">
</span>
<div align="center"><span onclick="SetCookie(thisCookie, 'yes')"><a href="http://www.enhibarrio.ning.com" target="_blank"><img src="http://api.ning.com/files/zCIZRipVEcAxFL27yTWvAY2M0p*IgZiMQm3hBAwf40EsgTXYJA wjD2xO2Q8AkPHyKpQr1VULEDiyj6n*ng8KfIt78wENm8j0/entraralblog.png" width="480" height="60" border="0" /></a></span></div>
<span onclick="SetCookie(thisCookie, 'yes')">
</span>
but the problem is that i want them to be able to come back to mainsite if they dont like secondsite.com, i need the code to expire the cookie if they want to come back to mainsite.com...