Web Analytics Made Easy -
StatCounter Full sceen image on site index, but only first time... - CodingForum

Announcement

Collapse
No announcement yet.

Full sceen image on site index, but only first time...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Full sceen image on site index, but only first time...

    Hi,
    I need the following...

    I need to put big pop-up image on site index that opens when visitor go to the first page of my web site. And then need option to close it. I know how to do it (without using javascript popups) using big div absolutely positioned on center with image in it, and then place X button on that div, and make it to display:none on the click on that X, and then full site shows up which basically was in background all the time. That is all managed with CSS.
    Now what I need is that once the image is closed when visitor goes to index again, it will not show again. I think that can be managed with javascript. Am I right?

    Thanks

  • #2
    Use a cookie.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

    Comment


    • #3
      Originally posted by Philip M View Post
      Use a cookie.
      Yes, I guessed.. thanks, but can you give me some link or something... cause I don't know how to make one... :/


      Edit: Ok, just had to use Google as usual...
      Tnx
      Last edited by GuitarLord; Apr 12, 2009, 03:25 AM.

      Comment


      • #4
        Code:
        <script type = "text/javascript">
        
        function createCookie(name,value,days) {
        	if (days) {
        		var date = new Date();
        		date.setTime(date.getTime() + (days*24*60*60*1000));
        		var expires = "; expires = "+ date.toGMTString();
        	}
        	else var expires = "";
        	document.cookie = name + "="+ value + expires + "; path=/";      // available throughout the directory
        }
        
        function readCookie(name) {
        	var nameEQ = name + "=";
        	var ca = document.cookie.split(';');
        	for(var i=0;i < ca.length;i++) {
        		var c = ca[i];
        		while (c.charAt(0)==' ') c = c.substring(1,c.length);
        		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
        	}
        	return null;
        }
        
        function eraseCookie(name) {
        	createCookie(name,"",-1);  // set cookie to expire on previous day
        }
        
        </script>
        name = whatever name you wish to give the cookie - say "seenImage"
        value = anything appropriate - say "theImage"
        days = number of days cookie to remain active (say 7)

        Of course, cookies can be erased by the user, and will only work if JavaScript is enabled.
        Last edited by Philip M; Apr 12, 2009, 03:41 AM. Reason: Typo

        All the code given in this post has been tested and is intended to address the question asked.
        Unless stated otherwise it is not just a demonstration.

        Comment

        Working...
        X