Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5958975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:37:12+00:00 2026-05-22T18:37:12+00:00

I want to have the div #topmessage slide down on the users second visit

  • 0

I want to have the div #topmessage slide down on the users second visit to the site. Also when the user clicks the #close the message will not be shown again. I guess I have to set a cookie and count it but not sure how. I have the following cookie plugin installed together with jquery http://plugins.jquery.com/files/jquery.cookie.js.txt

    <script type="text/javascript">
    jQuery(function($){ 
    $('#topmessage').delay(1000).slideDown(400);
    $("#close").click(function(){
          $("#topmessage").slideToggle(400);
        });

});
</script>
<div id="topmessage">
<a href="#" class="close" id="close">Close</a>
Hi welcome back, if you have any questions please feel free to <a href="/contact">contact me</a>.
</div>

Update: The reason I want to do this is to push the div to users who have visited the site once and are now returning on another date. I don’t just want to show the div the second time the site is loaded, but it has to be on another date or session as well. As far as I can see there is no way to access the creation date of a cookie?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T18:37:13+00:00Added an answer on May 22, 2026 at 6:37 pm

    This should work:

    <script type="text/javascript">
        $(function(){
            var value = $.cookie('the_cookie'),
                date = null;
            if (/^\d+$/.test(value || "")) {
                 date = new Date();
                 date.setTime(value);
            } else if ((value || "") == "") {
                 $.cookie('the_cookie', new Date().getTime());
            }
    
            if (null != date /* && date meets your requirements */){
                $('#topmessage').delay(1000).slideDown(400);
                $("#close").click(function(){
                    $("#topmessage").slideToggle(400);
                });
            }
        });
    </script>
    

    If you want to update the date in the cookie at each visit:

            if (/^\d+$/.test(value || "")) {
                 date = new Date();
                 date.setTime(value);
            }
            $.cookie('the_cookie', new Date().getTime());
    

    Working demo at: http://jsfiddle.net/roberkules/NL9jd/

    UPDATE

    added expiration date and path to cookie
    added 2nd cookie just for the session

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a div I want when user clicks on this div the background
I have a div that I want to appear based on user input (works),
I have a div with hight 300px I want to use slideDown or any
I have a div who are show as rectangle block. i want to show
I have a div tag in which there is an image in left corner
I have a div id=X within that i have multiple p , what i
I have a div 30px high and 500px wide. This div can contain two
I have a div full of text, photos, etc. It is generated dynamically, and
I want to understand how to implement HTML5 <audio> fallback using Javascript... i.e. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.