jQuery cookie setting

I am using the following js to set a cookie after the user sees an overlay. The problem is the cookie is only set when the user clicks OFF of the overlay. If they click a link WITHIN the overlay the cookie isn't set. How can I set the cookie even if they click a link within the overlay?

    $(function () {     $('#my-welcome-message').firstVisitPopup({         cookieName : 'homepage1',         showAgainSelector: '#show-message'     }); });   (function ($) {  'use strict';  $.fn.firstVisitPopup = function (settings) {      var $body = $('body');     var $dialog = $(this);     var $blackout;     var setCookie = function (name, value) {         var date = new Date(),             expires = 'expires=';         date.setTime(date.getTime() + 31536000000);         expires += date.toGMTString();         document.cookie = name + '=' + value + '; ' + expires + '; path=/';     }     var getCookie = function (name) {         var allCookies = document.cookie.split(';'),             cookieCounter = 0,             currentCookie = '';         for (cookieCounter = 0; cookieCounter < allCookies.length; cookieCounter++) {             currentCookie = allCookies[cookieCounter];             while (currentCookie.charAt(0) === ' ') {                 currentCookie = currentCookie.substring(1, currentCookie.length);             }             if (currentCookie.indexOf(name + '=') === 0) {                 return currentCookie.substring(name.length + 1, currentCookie.length);             }         }         return false;     }     var showMessage = function () {         $blackout.show();         $dialog.show();     }     var hideMessage = function () {         $blackout.hide();         $dialog.hide();         setCookie('fvpp' + settings.cookieName, 'true');     }      $body.append('<div id="fvpp-blackout"></div>');     $dialog.append('<a id="fvpp-close"></a>');     $blackout = $('#fvpp-blackout');      if (getCookie('fvpp' + settings.cookieName)) {         hideMessage();     } else {         showMessage();     }      $(settings.showAgainSelector).on('click', showMessage);     $body.on('click', '#fvpp-blackout, #fvpp-close', hideMessage);  };  })(jQuery); 

Replay

Category: javascript Time: 2016-07-28 Views: 0

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.237 (s). 12 q(s)