Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2010
    Posts
    37
    Thanks
    4
    Thanked 0 Times in 0 Posts

    quick cookie question

    using jquery and cookie plugin.

    i made a popup window. when the user clicks on a check box the window closes, forwards them to a new page, and then sets a cookie.

    i need it so that when they go back to the original page (where the popup came from) if the browser detects the cookie then the popup does not occur. I do not know why this does not work because when I alert the value of the cookie out, it gives me the correct number. something must be wrong in my logic ?
    code on the base page.
    Code:
     <script type="text/javascript">
    var test123 = $.cookie('FBCheck');
    		
    if ( test123 != 1212){ 
    function popup(Site)
    {
    window.open(Site,'PopupName','toolbar=no,statusbar=no, location=no,scrollbars=no,resizable=no,width=350,height=500')
    }
    }
    
    </script>
    code on popup (both files are in same directory)
    Code:
    $(document).ready(function() {
    	$("#Cbox").click(function() {
    	window.open ("http://www.google.com", "Google");
    	window.close();
    	$.cookie('FBCheck', '1212', {expires: 365, path: '/'});
    	
    	
    	
    							});
    						   });
    The jquery source is installed as is the plugin.

    Thanks so much for your help in advance!

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,396
    Thanks
    12
    Thanked 569 Times in 562 Posts
    Code:
    if ( test123 != 1212){ 
       function popup(Site)
       {
          window.open(Site, 'PopupName', 'toolbar=no, statusbar=no, location=no, scrollbars=no, resizable=no, width=350, height=500')
       }
    }
    What do you want to achieve with that code? Define the function only if test123 (which is a string) doesn't equal the numeric value 1212? Definitely not ...

    You wanted to OPEN the popup only if the cookie isn't set to "1212", so this is what you wanted to do
    Code:
    if ( test123 != "1212"){ 
       window.open(Site, 'PopupName', 'toolbar=no, statusbar=no, location=no, scrollbars=no, resizable=no, width=350, height=500')
    }


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •