- This topic has 10 replies, 3 voices, and was last updated 5 years, 10 months ago by David.
-
AuthorPosts
-
June 21, 2018 at 3:17 am #605031Mr McMarry
Hello Guys :
Code :
Javascript :
$(document).ready(function() { /****************** COOKIE NOTICE ******************/ if(getCookie('show_cookie_message') != 'no') { $('#cookie_box').show(); } $('.cookie_box_close').click(function() { $('#cookie_box').animate({opacity:0 }, "slow"); setCookie('show_cookie_message','no'); return false; }); }); function setCookie(cookie_name, value) { var exdate = new Date(); exdate.setDate(exdate.getDate() + (365*25)); document.cookie = cookie_name + "=" + escape(value) + "; expires="+exdate.toUTCString() + "; path=/"; } function getCookie(cookie_name) { if (document.cookie.length>0) { cookie_start = document.cookie.indexOf(cookie_name + "="); if (cookie_start != -1) { cookie_start = cookie_start + cookie_name.length+1; cookie_end = document.cookie.indexOf(";",cookie_start); if (cookie_end == -1) { cookie_end = document.cookie.length; } return unescape(document.cookie.substring(cookie_start,cookie_end)); } } return ""; }
CSS
#cookie_box { position: fixed; display: none; bottom: 0px; font-size: 0.8em; z-index: 1000; background:#393939; padding:5px; text-align:center; width:99%; color:#ffffff; } #cookie_box a:hover { color:#ffffff; text-decoration: underline }
HTML
<div id="cookie_box">Our site requires cookies to function, <a href="/cookies">click here</a> for more information <a href="#" class="cookie_box_close">Close [X]</a></div>
i dont know whats wrong with the code when i remove display none and position fixed css it appears on site but dont close when i click close javascript is placed right tooo
June 21, 2018 at 4:05 am #605060Mr McMarryUsed jQuery(function ($) over $(document).ready(function()
SOLVED
June 21, 2018 at 6:56 am #605183DavidStaffCustomer SupportGlad to hear you got it resolved.
June 21, 2018 at 1:55 pm #605603Mr McMarrySorry about this but when I click close X its opacity changes to 0, it doesn’t change to display: none; ?
which results in: no hover or click on the top navigation menu. Because its changes to opacity 0 i want it to display: none when i click X
June 21, 2018 at 9:45 pm #605748TomLead DeveloperLead DeveloperInstead of:
$('#cookie_box').animate({opacity:0 }, "slow");
Try:
$('#cookie_box').animate({opacity:0 }, "slow").hide();
June 22, 2018 at 12:52 am #605811Mr McMarryWow, it Worked.
Is this Code ok I mean is there some bug?
June 22, 2018 at 1:07 am #605821DavidStaffCustomer SupportHi Arish, code looks fine, the author had not considered the ‘blocking’ event. Glad you got this resolved.
June 22, 2018 at 2:00 am #605858Mr McMarryCan we add blocking event? i dont want to have any mess for this
June 22, 2018 at 2:05 am #605860DavidStaffCustomer SupportHi Arish, what i meant was the author hadn’t considered that the container could block content behind it. The code is fine as is.
June 22, 2018 at 2:24 am #605875Mr McMarryoh, Very Well we solved it.
Thank You DAVID and TOM
June 22, 2018 at 2:26 am #605877DavidStaffCustomer SupportYou’re welcome, I am glad Tom could help 😉
-
AuthorPosts
- You must be logged in to reply to this topic.