SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard donboe's Avatar
    Join Date
    Jun 2010
    Location
    Netherlands
    Posts
    2,067
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript popup on page load

    I have a popup window on my index page that is loading on page load. Is there a way to integrate a cookie so that it only appearswhen a certain cookie doesnt exist? This is the Javascript I am using for the popup window:
    Code:
    $(function(){
    	var overlay = $('<div id="overlay"></div>');
    	overlay.show();
    	overlay.appendTo(document.body);
    	$('.popup').show();
    	$('.close').click(function(){
    	$('.popup').hide();
    	overlay.appendTo(document.body).remove();
    	return false;
    });
    
    $('.x').click(function(){
    	$('.popup').hide();
    		overlay.appendTo(document.body).remove();
    		return false;
    	});
    });
    
    $(document).ready(function(){
    		$('.wrapper').hide().fadeIn(1000);
    });
    Thank you in advance!
    “Good artists copy, great artists steal” (Pablo Picasso - 1934)

  2. #2
    Grüße aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,889
    Mentioned
    210 Post(s)
    Tagged
    12 Thread(s)
    Hi donboe,

    Quote Originally Posted by donboe View Post
    I have a popup window on my index page that is loading on page load. Is there a way to integrate a cookie so that it only appears when a certain cookie doesnt exist?
    Sure is!
    If I was you, I'd use jQuery cookie (as you're using jQuery anyway).
    A while back I wrote a tutorial about how to use cookies with style switchers. You should be able to apply what's described there to your current problem.

    If you get stuck just give me a shout.


Bookmarks

Posting Permissions

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