Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
javascript - setting cookies OnClick
Old 09-27-2004, 08:41 AM javascript - setting cookies OnClick
Junior Talker

Posts: 1
Trades: 0
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 08:43 AM.. Reason: e-mail notification
65pbiz is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to javascript - setting cookies OnClick
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.24531 seconds with 12 queries