SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Git-R-Done
    Join Date
    Nov 2001
    Posts
    1,194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cookie That Loads Popup Window If Link Hasn't Been Clicked

    I need to make a cookie that will load a popup window on the main page of my site if the visitor hasn't clicked on a certain link within my site. Can somebody tell me how this can be done? I would think it could be done by modifying a small part of the script below.

    Code:
    <script>
    function getCookie(NameOfCookie){
        if (document.cookie.length > 0) {              
        begin = document.cookie.indexOf(NameOfCookie+"=");       
        if (begin != -1) {           
          begin += NameOfCookie.length+1;       
          end = document.cookie.indexOf(";", begin);
          if (end == -1) end = document.cookie.length;
            return unescape(document.cookie.substring(begin, end));
        } 
      }
      return null;
    }
    
    function setCookie(NameOfCookie, value, expiredays) {
    var ExpireDate = new Date ();
    ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
    
      document.cookie = NameOfCookie + "=" + escape(value) + 
      ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
    }
    
    function DoTheCookieStuff()
    {
     visited=getCookie('visited');
     if (visited==null) 
     {
    setCookie('visited','yes',365)
    MyWindow=window.open('http://www.site.com','MyWindow','toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=640,height=480,left=1,top=1');
     }
    }
    </script>
    Code inserted in <body> tag:

    onLoad="DoTheCookieStuff()"

    Link that contains the code to set the cookie saying the visitor has downloaded the file:

    <a href="info.doc" onClick="setCookie()">Download</a>

    Note: the page that contains the download is different than the main page.

    Any suggestions would be greatly appreicated.


    Regards,

    John Saunders

  2. #2
    SitePoint Addict -TheDarkEye-'s Avatar
    Join Date
    Mar 2001
    Location
    canada
    Posts
    286
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think this belongs in the javascript forum, unless you want us to tell you how to set that cookie using coldfusion or java?

  3. #3
    Git-R-Done
    Join Date
    Nov 2001
    Posts
    1,194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK....I must have over looked the Javascript forum. I figured it would be under the Program Your Site section and the only thing I saw was Java.


    John


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
  •