Div pop up once a day

Discussion in 'JavaScript' started by 00lewis, Jun 9, 2009.

  1. #1
    hello there,

    I've been trying to create a pop up div, to explain to viewers that the site they are on is small collection of products and if they want to see our full range click link in the box,

    here is the example of what i'm working with, this is just a test screen at the moment. http://www.emlltd.com/pop_up/test%205.html

    but before i put this up on our shopping basket i would like it to only pop up once a day, I've tried to research this loads and have experimented with various cookie scripts but still can't work it out,

    I have also looked at this thread but cant manage to get it to work for me.....
    http://forums.digitalpoint.com/showthread.php?t=1175576

    if anyone could help i would be very greatful.

    kind regards
     
    00lewis, Jun 9, 2009 IP
  2. Logic Ali

    Logic Ali Well-Known Member

    Messages:
    170
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #2
    You need to decide how to present to users with JS disabled/not available, who can't clear the div.

    Get rid of onload=checkCookie, it's generating an error.

    You'll find several cookie utilities, but let's say you use this one.

    By default, that div should be styled display:none, otherwise it can't be removed when JS is disabled. This code assumes that to be the case. Place it anywhere below the div:
    
    <script type = 'text/javascript' src = 'xcookie.js'></script>
    
    <script type = 'text/javascript'>
    
    if( !XCookie.exists( 'shownDiv' ) )
     document.getElementById( 'hideshow' ).style.display = 'block';
    
    XCookie.set( 'shownDiv', 1, 1 );
    
    </script>
    
    Code (markup):
     
    Logic Ali, Jun 11, 2009 IP
  3. Unni krishnan

    Unni krishnan Peon

    Messages:
    237
    Likes Received:
    9
    Best Answers:
    2
    Trophy Points:
    0
    #3
    The following code check whether a cookie with a specified name is available.
    If available, then it hides a div.
    If not, then it creates a new cookie with expiry period as 1 day.



    Hope this code helps. :)
     
    Unni krishnan, Jun 15, 2009 IP