SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard Anat's Avatar
    Join Date
    Oct 2000
    Posts
    1,281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Help! I need a readymade pop up javascript

    I am javascript illiterate All of the scripts on my website are free scripts I picked up from various JS sites (I can do that at least )

    Now, I'm looking for a very specific JS script to add a pop up window that will encourage people to join my mailing list and I can't seem to find one anywhere:

    I want a pre-sized pop-up window that will load automatically, but only once per user. I need the script to install a cookie that will prevent the pop up from popping up every time the visitor comes back.

    Two other requirements that will be welcome:

    1. I want to place the script on two different pages on my website - one would be the homepage and the other would be the forums main page. That's because many people go directly to the forums and might miss the pop up if I don't place it there as well. However, I want the cookie to work here too - visitors that do visit both pages should still get the pop up only once.

    2. If at all possible, it would be nice to have a "remind me later" feature, so that users can opt to have the pop up re-emerge on their next visit. That way the pop up with end with one of 3 options - 1-subscribe to the list now, 2- kill the pop up forever 3- be reminded again next time they visit the site.

    If anyone has such a ready made script they're willing to share - I'll be most grateful (you could just direct me to your web page and I'll pick up the script there). Alternatively, if you know where I can find such a free script, that'd be cool too

    Many thanks in advance!
    My Web Publishing Blog: B6S.net - I dofollow but don't spam!
    Follow me on Twitter
    My favorite content writer:
    Steve Snedeker

  2. #2
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A simple solution:

    <html>
    <head>
    <script language="javascript">
    function popup()
    {
    if(getCookie('nomorepopup') == 'true')
    {
    alert('No popup for you');
    }
    else
    {
    openWin('somepage.htm', 200, 200);
    setCookie('nomorepopup', 'true');
    }
    }
    function setCookie(name, value)
    {
    document.cookie = name+'='+value+'; expires=Thu, 01-Jan-70 00:00:01 GMT';
    }
    function getCookie(name)
    {
    var i = 0;
    while(i < document.cookie.length)
    {
    var j = i + name.length;
    if(document.cookie.substring(i, j) == name)
    {
    var k = document.cookie.indexOf(';', j);
    if(k == -1){k = document.cookie.length};
    return unescape(document.cookie.substring(j + 1, k));
    }
    i++;

    }
    return '';

    }
    function openWin(url, width, height)
    {
    window.open(url,'','toolbar=no,scrollbars=auto,resizable=no,width='+width+',height='+height);
    }
    </script>
    </head>
    <body onLoad="popup()">
    <p>Blah blah blah</p>
    </body>

    </html>

    The other requirements:
    1) If the two pages are located on the same server (same domain), you don't have to do anything extra
    2) Add an if(confirm('Remind me later') == false) statement in front of the setCookie call
    Last edited by jofa; Jun 2, 2002 at 20:44.

  3. #3
    SitePoint Wizard Anat's Avatar
    Join Date
    Oct 2000
    Posts
    1,281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you so much!



    I'll try this as soon as I can and I'll let you know how it goes.
    My Web Publishing Blog: B6S.net - I dofollow but don't spam!
    Follow me on Twitter
    My favorite content writer:
    Steve Snedeker

  4. #4
    SitePoint Wizard Anat's Avatar
    Join Date
    Oct 2000
    Posts
    1,281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I could see it working... at least once that's when the cookie went into effect and I couldn't check the script any longer.

    This must be a dumb question, but how do I clear this specific cookie? I tried looking at the cookies folder in the windows folder but I can't find it by date and I don't know what's it called.

    Help!
    My Web Publishing Blog: B6S.net - I dofollow but don't spam!
    Follow me on Twitter
    My favorite content writer:
    Steve Snedeker


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
  •