最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Create cookie if link clicked, redirects to clicked link on next visit - Stack Overflow

programmeradmin3浏览0评论

Site has two sections; 'Everywhere' and 'LA'.
Default is 'Everywhere' section.

How would I go about creating a cookie if the visitor clicks the 'LA' section link and when they return to the main site on another visit, they are redirected to that 'LA' section?

I've tried altering this script; .html

Instead of checkboxes, its a link and only one. But doesn't seem to work.

Site has two sections; 'Everywhere' and 'LA'.
Default is 'Everywhere' section.

How would I go about creating a cookie if the visitor clicks the 'LA' section link and when they return to the main site on another visit, they are redirected to that 'LA' section?

I've tried altering this script; http://www.javascriptsource./cookies/cookie-redirect.html

Instead of checkboxes, its a link and only one. But doesn't seem to work.

Share edited Jun 12, 2018 at 14:17 Jonathan Hall 79.9k19 gold badges159 silver badges203 bronze badges asked Nov 9, 2012 at 17:54 Tad WardTad Ward 2792 silver badges8 bronze badges 1
  • Javascript is well and good, but this kind of work is better suited for server-side handling. – TheZ Commented Nov 9, 2012 at 17:57
Add a ment  | 

2 Answers 2

Reset to default 4

What I do usually is create a conditional, and create an embed with the cookie inside. I also tend to use this add-on: http://devot-ee./add-ons/cookies

Tad,

For setting the cookie you are going to want to use javascript, using a click handler on the LA section link. If you need some help with setting the cookie in javascript there is a good introductory article at http://www.quirksmode/js/cookies.html which isn't bang up to date but is still in full working order.

Once the cookie is set then you will switch to using one of the plugins for EE so that you can check for the existence of it in a template (probably in the an embeded or snippeted template) on page load. If you find the cookie then you can use the standard EE redirect syntax to send the visitor to the relevant section.

发布评论

评论列表(0)

  1. 暂无评论