SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Cookie Question

  1. #1
    SitePoint Member
    Join Date
    Sep 2000
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I want my webpage to have a splash screen. When the visitor enters the site, he/she will see a picture and then he/she will enter the site by clicking on it. But I also want the visitors who don't want to see the picture anymore be able to disable it. So I think I have to use a cookie. But I don't know how. Does anybody know a tutorial or have a premade one ?

    Thanks

  2. #2
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    the easiest to understand cookie tutorial I've seen is at http://htmlgoodies.earthweb.com

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  3. #3
    ********* Addict DLG_1's Avatar
    Join Date
    Jun 2000
    Location
    Texas, USA
    Posts
    596
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    on the html have a checkbox that disables the splash screen.

    in the form tag, have a name attribute like: tForm

    then have an event handler on the checkbox like
    <input type..... name="checkBox2" onChange="usrPref()">

    in between your <head> tags type this in exactly:
    Code:
    <script language="javascript>
    splash = "yes"
    function usrPref() {
    if (document.tForm.checkBox2.checked == true){
        expDate = "12/01/2001"
        document.cookie="splash=no" + ";expires=" + expDate
        }
    
    }
    
    function chkUsrPref(){
      allCookies = document.cookie
      splash = allCookies.indexOf("splash")  // should return no                                          //  or yes
    
    }
    </script>
    then in the body tag have another event handler:

    <body .... onLoad="chkUsrPref()">


    i think that you should get the drift by now...i wrote this in three minutes so there are bound to be problems.

    Sam


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
  •