# Need to cap frequency on a jquery slideDown slideUp

**URL:** <https://forum.kirupa.com/t/need-to-cap-frequency-on-a-jquery-slidedown-slideup/242587>\
**Category:** web dev\
**Created:** [October 28, 2007, 12:54am UTC](https://forum.kirupa.com/t/need-to-cap-frequency-on-a-jquery-slidedown-slideup/242587 "2007-10-28T00:54:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![somnamblst](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@somnamblst](https://forum.kirupa.com/u/somnamblst)\
**Post date:** [October 28, 2007, 12:54am UTC](https://forum.kirupa.com/t/need-to-cap-frequency-on-a-jquery-slidedown-slideup/242587/1 "2007-10-28T00:54:34Z")

</div>

My function slides a div called slidebar down & then back up without user interaction. I would like returning visitors to not see the div slide. I have a cookie that worked with my scriptaculous sliding div, that doesn’t work with my much smoother JQuery one.

My function

```auto

 
$(document).ready(function() { 
        initSlideboxes(); 
 
        function initSlideboxes() 
 
{ 
$('#slidebar').slideDown("normal"); 
setTimeout(function() 
{ 
  $('#slidebar').slideUp(3000); 
 
}, 5000); 
 
 
        $('#slidebartrigger').click(function(){$ 
('#slidebar').slideToggle(); }); 
 

```

A JQuery cookie I found on the jquery group

```auto
Index: cookie/jquery.cookie.js 
--- cookie/jquery.cookie.js (revision 1611) 
+++ cookie/jquery.cookie.js (working copy) 
@@ -17,13 +17,17 @@ 
  * @desc Create a cookie with all available options. 
  * @example $.cookie('the_cookie', 'the_value'); 
  * @desc Create a session cookie. 
+ * @example $.cookie('the_cookie', null); 
+ * @desc Delete a cookie by passing a null value. 
  * @example $.cookie('the_cookie', '', {expires: -1}); 
  * @desc Delete a cookie by setting a date in the past. 
  * 
  * @param String name The name of the cookie. 
  * @param String value The value of the cookie. 
  * @param Object options An object literal containing key/value pairs to provide optional cookie attributes. 
- * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object. 
+ * @option Time|Number|Date expires Either a time specified as an integer followed by a unit abbreviation character 
+ * (y: years, w: weeks , d: days, h: hours, m: minutes, s: seconds) 
+ * or an integer specifying the expiration date from now on in days or a Date object. 
  * If a negative value is specified (e.g. a date in the past), the cookie will be deleted. 
  * If set to null or omitted, the cookie will be a session cookie and will not be retained 
  * when the the browser exits. 
@@ -55,15 +59,34 @@ 
 jQuery.cookie = function(name, value, options) { 
     if (typeof value != 'undefined') { // name and value given, set cookie 
         options = options || {}; 
+ if (value === null) { 
+ value = ""; 
+ options.expires = -1; 
+ } 
         var expires = ''; 
- if (options.expires && (typeof options.expires == 'number' || options.expires.toGMTString)) { 
+ if (options.expires) { 
             var date; 
- if (typeof options.expires == 'number') { 
+ if (typeof options.expires == 'string' && options.expires.match(/^[+-]?[0-9]+[ywdhms]$/) !== null) { 
+ var match = options.expires.match(/^([+-]?[0-9]+)([ywdhms])$/); 
+ options.expires = parseInt(match[0], 10) * (({ 
+ "y": (60 * 60 * 24 * 365), 
+ "w": (60 * 60 * 24 * 7), 
+ "d": (60 * 60 * 24), 
+ "h": (60 * 60), 
+ "m": (60), 
+ "s": (1) 
+ }[match[1]]) || 0); 
                 date = new Date(); 
- date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)); 
- } else { 
+ date.setTime(date.getTime() + options.expires * 1000); 
+ } 
+ else if (typeof options.expires == 'number') { 
+ date = new Date(); 
+ date.setTime(date.getTime() + options.expires * 24 * 60 * 60 * 1000); 
+ } 
+ else if (typeof options.expires.toGMTString != 'undefined') 
                 date = options.expires; 
- } 
+ else 
+ throw "invalid \"expires\" option"; 
             expires = '; expires=' + date.toGMTString(); // use expires attribute, max-age is not supported by IE 
         } 
         var path = options.path ? '; path=' + options.path : ''; 

```
