SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jun 2000
    Location
    Newnan,Georgia,USA
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was wondering if any you of you guys know of a code (if one exists) that lets you have a pop-up window that can have like buttons that allow the person to choose :
    "Close this window forever"
    "Or don't ask me again"

    and when they click that they pop-up closes and never shows up again for that person.

  2. #2
    SitePoint Enthusiast GodFather's Avatar
    Join Date
    Aug 2000
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You would have to use a cookie, and have the box read the cookie, if it wasnt there, it would popup, and if the cookie was there it wouldnt popup the box

  3. #3
    SitePoint Evangelist Caesar's Avatar
    Join Date
    May 2000
    Location
    On some harddisk
    Posts
    599
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah, that's it but what he needs is the code ....

  4. #4
    SitePoint Wizard
    Join Date
    Sep 1999
    Posts
    1,390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can't help with the code, but cookies won't keep the window from ever popping up on EVERYONE's computer. People with cookies disabled or an old browser will get the popup forever.

    ------------------
    Aidan Bahta
    abahta@activewm.com

    ActiveWM.com - The place for the Active Webmaster.

  5. #5
    SitePoint Enthusiast GodFather's Avatar
    Join Date
    Aug 2000
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes, thats true, there is no way to make the popup box never showup again. And I cant help you with the cookie code myself, I am still learning cookies as well. Sorry that I couldnt be of any more help

  6. #6
    ********* Addict
    Join Date
    Feb 2000
    Location
    NE FL, USA
    Posts
    301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this

    Code:
    <SCRIPT LANGUAGE="JavaScript">
    
    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 = (2 < argc) ? argv[2] : null;
    var path = (3 < argc) ? argv[3] : null;
    var domain = (4 < argc) ? argv[4] : null;
    var secure = (5 < argc) ? 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 DisplayInfo() {
    var expdate = new Date();
    var visit;
    expdate.setTime(expdate.getTime() +  (24 * 60 * 60 * 1000 * 365)); 
    if(!(visit = GetCookie("visit"))) 
    visit = 0;
    visit++;
    SetCookie("visit", visit, expdate, "/", ".your-domain-name.com", false);
    var message;
    if(visit == 1) 
    popup()
    }
    
    
    /////////////editable part///////////////////////////////////////
    function popup(){
    window.open('http://www.your-domain-name.com/popup.html','win1','width=550,height=440,resizable')
    }
    
    /////////////editable part///////////////////////////////////////
    </script>
    Here's how it works:

    1.) Paste between the head tags on every page that you want it to pop-up when that page is left.

    2.) Change the URL (highlighted in red) of the pop up to the location of it on your site.

    3.) Put: OnUnload="DisplayInfo() at the very end of the BODY tag on every page that you use the JavaScript on. This is what it looks like in my BODY tag: <body bgcolor="#FFFFFF" OnUnload="DisplayInfo()">

    3.) Fiddle around with the width and height settings (highlighted in green) to make sure that the window that opens isn't too big or too small. Temporarily disable cookies while testing the script in order to see the pop-up every time.

    4.) Change your-domain-name.com to your actual domain. If you are hosted by a free web space provider like geocities.com, use your directory there. For example you would replace .your-domain-name.com with .yourisp.com/mysite/ -- notice the period in front of the domain.

    5.) Upload the file. You're done.

    On the page that you have pop up, just add the following:
    Code:
    <p>No thanks, <a href="javascript: self.close()">close 
      this window</a>.</p>
    The cookie that writes to the computer will make it so that this pop-up never sows up again. You can make it so that it will come up every month, with a little bit of cookie know-how. I originally got this from what used to be sitepoint, webmaster-resoures.com.


    Mike
    Brain Bucket Magazine - Biker News, Views, and Event Coverage.


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
  •