Results 1 to 3 of 3

Thread: [RESOLVED] Jquery modal window with cookie

  1. #1
    Join Date
    May 2009

    resolved [RESOLVED] Jquery modal window with cookie

    Hi there,

    I was wondering if anybody can help me? I know what I need to do...but just not sure how to go about doing it. I'm not a whizz at javascript / jquery, so any help any one can give, or point me in the right direction of a tutorial would be much appreciated...

    I want to have a jquery modal window which displays automatically when a user visits the site (preferably at any page). This modal window would then contain a disclaimer message with an 'OK' button to acknowledge the user has read the disclaimer. When the OK button is pressed, the modal window closes and the user is free to browse the rest of the site - the modal window would not display again on any other page, nor if the user visits the site at another time.

    Now, in theory, i know I need some code for a jquery window that automatically displays, and then have to set a cookie to ensure that the browser doesn't display it again, but I'm just not sure which is the best method to go about it. Can anyone recommend a tutorial or point me in the right direction to achieve what I need to?

    Thanks in advance

  2. #2
    Join Date
    May 2009
    OK, so I muddled through it yesterday, and here's how I've achieved the above:

    I used the following auto loading modal window:


    And then applied the following code to enable the cookie:
    <script src="modal2_files/jquery.cookie.js" type="text/javascript"></script>
    jQuery(document).ready(function($) {
      if ($.cookie('the_cookie')) { 
      else { 
      launchWindow('#dialog');//qual vc vai abrir
    	//if close button is clicked
    	$('.window .close').click(function (e) {
    		//Cancel the link behavior
    	//if mask is clicked
    	$('#mask').click(function () {
         $.cookie('the_cookie', 'the_value'); // set cookie

  3. #3
    Join Date
    Nov 2013

    Thank you for your reply on how to apply the cookie on the modal. I downloaded the jquery.cookie plugin, and then I pasted the above code so I can activate the cookies. It seems the cookie function is not working because i keep seeing the modal window every time I refresh. What I'm trying to achieve is have modal window to open only on the first visit, until the user clears their browser cookie. Thanks.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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