Results 1 to 2 of 2

Thread: Cookie Splash Page

  1. #1
    Join Date
    Dec 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Cookie Splash Page

    Hi there...
    I've been searching for a script which will show a splash screen... But it's not that simple... Here's the scenerio:
    I'm designing a website which has three sections:
    1. The Website (About Us etc..)
    2. The Blog (activities, events, etc...)
    3. The Forums (community, discussion, etc.)


    So I have designed a sort of graphical splash screen which is a little like this:

    Code:
    Welcome to [Company]
    Please Select your Destination:
    
    • The Website [button]
    • The Blog [button]
    • The Forums [button]
    (Notice that the listed items are actually graphical buttons which the users can click on (onmouseover events with hyperlinks)

    OK. So now you know where I'm trying to get at...
    I want some sort of cookie so that the user does not have to select his/her "destination" every time they go to the main index.html page. I want some sort of check or tick box which says "Do not show me this again" or "Remember my choice", in which case, the user's option is remembered in a cookie (or other) so that the browser redirects him to the right page every time he enters.

    I know I'm asking alot, but I'm quite sure it's possible.
    Thanks for your ideas, thoughts, and help. This is much appreciated!

  2. #2
    Join Date
    Dec 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Found it!
    Here's the source code example for anyone who needs it!
    Enjoy
    HTML Code:
    <!-- TWO STEPS TO INSTALL COOKIE REDIRECT:
    
      1.  Copy the coding into the HEAD of your HTML document
      2.  Add the last code into the BODY of your HTML document  -->
    
    <!-- STEP ONE: Paste this code into the HEAD of your HTML document  -->
    
    <HEAD>
    
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Original:  Ronnie T. Moore -->
    <!-- Web Site:  JavaScript Source Code 3000 -->
    
    <! >
    <! >
    
    <!-- Begin
    var expDays = 30;
    var exp = new Date(); 
    exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
    
    function getCookieVal (offset) {  
    var endstr = document.cookie.indexOf (";", offset);  
    if (endstr == -1)    
    endstr = document.cookie.length;  
    return unescape(document.cookie.substring(offset, endstr));
    }
    function GetCookie (name) {  
    var arg = name + "=";  
    var alen = arg.length;  
    var clen = document.cookie.length;  
    var i = 0;  
    while (i < clen) {    
    var j = i + alen;    
    if (document.cookie.substring(i, j) == arg)      
    return getCookieVal (j);    
    i = document.cookie.indexOf(" ", i) + 1;    
    if (i == 0) break;   
    }  
    return null;
    }
    function SetCookie (name, value) {  
    var argv = SetCookie.arguments;  
    var argc = SetCookie.arguments.length;  
    var expires = (argc > 2) ? argv[2] : null;  
    var path = (argc > 3) ? argv[3] : null;  
    var domain = (argc > 4) ? argv[4] : null;  
    var secure = (argc > 5) ? argv[5] : false;  
    document.cookie = name + "=" + escape (value) + 
    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
    ((path == null) ? "" : ("; path=" + path)) +  
    ((domain == null) ? "" : ("; domain=" + domain)) +    
    ((secure == true) ? "; secure" : "");
    }
    function DeleteCookie (name) {  
    var exp = new Date();  
    exp.setTime (exp.getTime() - 1);  
    var cval = GetCookie (name);  
    document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
    }
    
    var favorite = GetCookie('animal');
    
    if (favorite != null) {
    switch (favorite) {
    case 'cat' : 	url = 'cat.html'; // change these!
    	     	break;
    case 'dog' : 	url = 'dog.html'; 
    	     	break;
    case 'gerbil' : url = 'gerbil.html';
    		break;
    case 'gopher' : url = 'gopher.html';
    		break;
    }
    window.location.href = url;
    }
    //  End -->
    </script>
    </HEAD>
    
    <!-- STEP TWO: Copy this code into the BODY of your HTML document  -->
    
    <BODY>
    
    <center>
    <form>
    <table><tr><td>
    Please choose your Favorite Pet:<br>
    <input type=checkbox name="cat" onClick="SetCookie('animal', this.name, exp);">Cat<br>
    <input type=checkbox name="dog" onClick="SetCookie('animal', this.name, exp);">Dog<br>
    <input type=checkbox name="gerbil" onClick="SetCookie('animal', this.name, exp);">Gerbil<br>
    <input type=checkbox name="gopher" onClick="SetCookie('animal', this.name, exp);">Gopher<br>
    </td></tr>
    </table>
    </form>
    </center>
    Forgot to mention the source: (silly me )
    http://javascript.internet.com/cooki...-redirect.html

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
  •