I have been successfully using a cookie redirection script to determine if a visitor had seen the page that day and if so redirect them to another.
This is what I used
/* Copyright http://www.perlscriptsjavascripts.com
Free and commercial Perl and JavaScripts */
// page to go to if cookie exists
go_to = "http://next page.htm";
// 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);
if (start == -1){
document.cookie = "seenit=yes; expires=" + ged(num_days);
} else {
window.location = go_to;
}
}
readCookie("seenit");
// -->
</script>
and it works fine
However I would ideally like to set the cookie when a link was clicked not when the page first loads
I tried an OnClick command along with the banner and link in the body section
but then I got lost.
what do I place in the head section
what do I remove to stop it from setting the cookie onload.
I want to set a cookie when a banner is clicked
and if that cookie is found, go_to new link
I would be grateful if someone could help me
Thanks
Richard
Last edited by 65pbiz : 09-27-2004 at 07:43 AM.
Reason: e-mail notification
|