DTML pop up help? Sessions cookies - I'm frustrated!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • iMind
    Confirmed User
    • Nov 2007
    • 937

    #1

    DTML pop up help? Sessions cookies - I'm frustrated!

    Sorry, my last thread wasn't named properly enough to target the right help

    I have a site and I want to display a div layer on it, but only ONCE per session..
    as to not annoy surfers.

    So basically they come on to the site, see the DIV pop up, click it or click close, and if they click close it sets a cookie, so it's not shown again

    I'm pulling my fucking hair out here.

    I tried modifying the code I found here, http://cssbeauty.com/skillshare/disc...using-cookies/

    but the layer pops up, then disappears..

    Any help in the right direction would be appreciated
  • Malicious Biz
    So Fucking Banned
    • Mar 2005
    • 4575

    #2
    iMind is a communist

    Comment

    • iMind
      Confirmed User
      • Nov 2007
      • 937

      #3
      bump

      Comment

      • qwe
        Confirmed User
        • Jul 2003
        • 2109

        #4
        it has to be that mac you own

        Comment

        • iMind
          Confirmed User
          • Nov 2007
          • 937

          #5
          Originally posted by qwe
          it has to be that mac you own
          yeah, that must be it.

          retard.

          Comment

          • Alky
            Confirmed User
            • Apr 2002
            • 5651

            #6
            why not just start the session when you load the div, not when they click close..just an idea.

            didnt look at the code, but maybe the onclose isnt working right or something.

            Comment

            • iMind
              Confirmed User
              • Nov 2007
              • 937

              #7
              Thanks for the suggestions Alky..

              Sadly my knowledge of code ends at HTML, so I'm havin a hard time doing anything with that script, was hoping there was a simple solution but doesn't seem to be

              Comment

              • Alky
                Confirmed User
                • Apr 2002
                • 5651

                #8
                Originally posted by iMind
                Thanks for the suggestions Alky..

                Sadly my knowledge of code ends at HTML, so I'm havin a hard time doing anything with that script, was hoping there was a simple solution but doesn't seem to be
                PHP Code:
                session_start();
                if(!$_SESSIONS["ldhtml"]) {
                $_SESSIONS["ldhtml"]="1";
                //LOAD DHTML
                } 
                
                something like that should work

                Comment

                • iMind
                  Confirmed User
                  • Nov 2007
                  • 937

                  #9
                  hmm, perhaps it's time I take a PHP course..

                  Currently I'm using this

                  PHP Code:
                  <script language="javascript" type="text/javascript">
                    <!--
                     function getCookie(name){
                      if(document.cookie!=""){
                        var cookie=document.cookie;
                        var start=cookie.indexOf(name);
                        var stop;
                  
                        if(start!=-1){
                          start+=name.length+1;
                          stop=cookie.indexOf(';', start);
                  
                          if(stop==-1)
                            stop=cookie.length;
                          return unescape(cookie.substring(start, stop));
                        }
                      }
                      else
                        return false;
                    }
                  
                    function makeCookie(name, value){
                      var cookie = name + '=' + escape(value) + ';';
                      document.cookie = cookie;
                    }
                  
                    function showhide(id, setcookie){
                      if(setcookie==true){
                        var cookie=getCookie('show');
                        var show=new Array();
                        if(cookie) {show=cookie.split(', ');}
                        var invar=-1;
                  
                      for(i=0; i < show.length; i++)
                        if(show[i]==id)
                          invar=i;
                      }
                  
                      if(document.getElementById(id).style.display=="none"){
                        document.getElementById(id).style.display="block";
                  
                        if(invar==-1 && setcookie==true)
                          show[show.length]=id;
                      }
                      else{
                        document.getElementById(id).style.display="none";
                  
                        if(invar!=-1 && setcookie==true)
                          show.splice(invar, 1);
                      }
                  
                      if(setcookie==true)
                        makeCookie('hide', show.join(', '));
                    }
                  
                    function init(){
                      showhide('container', false)
                  
                      var cookievalue=getCookie('show');
                      var show;
                  
                      if(cookievalue!=""){
                        show=cookievalue.split(', ');
                  
                        for(i=0; i < show.length; i++)
                          document.getElementById(show[i]).style.display="block";
                      }
                    }
                    -->
                    </script> 
                  
                  and then

                  PHP Code:
                        <a href="javascript:showhide('container', false)">Close This Window!</a> 
                  

                  It closes alright, but if I refresh the page it shows again

                  Comment

                  • Alky
                    Confirmed User
                    • Apr 2002
                    • 5651

                    #10
                    where are you calling init from?

                    Comment

                    • iMind
                      Confirmed User
                      • Nov 2007
                      • 937

                      #11
                      Originally posted by Alky
                      where are you calling init from?
                      from the body tag
                      onload=init()

                      Comment

                      • iMind
                        Confirmed User
                        • Nov 2007
                        • 937

                        #12
                        it's working .. but flashes real quick, which obviously is unsuitable

                        Comment

                        Working...