View Full Version : Redirecting Questions

08-07-2008, 11:42 PM
Hi I was wondering if you could give me a few clues on this and how I might achieve it...

On my site I want a user to be able to click a link that checks for a cookie and either takes him to a disclaimer page on his first visit (where he must choose to continue, or not, in which case he is redirected). Alternatively, if the cookie has already been approved the page does not reappear and the link that checked for the cookie would simply take the user to the desired page minus the redirect to the disclaimer page. I would want this check on multiple pages, and what I forsee as my main problem is this - when the user accepts the disclaimer I would want him to be taken to the page he would have been taken to before he was redirected (so if he clicked a link called "image gallery" and it checked to see if a cookie existed and it did not, he would be taken to the disclaimer page, where he would need to click OK, and then be taken to the image gallery page, but this, obviously for multiple pages). I hope that is clear, I don't know how else to explain it. Any hints or tips on what to look up would be most appreciated (I have searched quite a bit for redirect on Google, but nothing that would really help with that last part).

08-08-2008, 07:56 PM
one way to do it is to add a (css) class to all the hyperlinks that need to check the disclaimer and, based on the presence of this class attach an onclick event handler (on document load) that checks for the disclaimer cookie. Also, this event handler has to pass the href of the clicked hyperlink to the disclaimer page so that the user can be redirected to the page he was visiting.

the advantage of this method is that all you have to do is put all the js in one file and include it in all ur html files and simply add the disclaimer class to get the functionality :)