SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Zealot BobM's Avatar
    Join Date
    Jun 2000
    Location
    Tucson, AZ, USA
    Posts
    164
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey everyone,

    I'm thinking of putting a pop-up on one of my sites using the following javascript. I only want it to pop-up when a visitor visits every 25 days or so. Can someone tell me where I put the code for that in the below script or point to a script where this is already done?

    Thanks,

    ------------------------------------------------

    <SCRIPT LANGUAGE="JavaScript">
    <!-- begin

    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, "/", ".movie-fever.com", false);
    var message;
    if(visit == 1)
    popup()
    }

    function popup(){
    window.open('popup.html','','toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=1,width=500,height=425')
    }

    // end -->
    </SCRIPT>

    Bob Messinger
    Movie-Fever.com - News, Reviews, Trailers..
    Movie Fever Forums - Visit and discuss movies with other fans!

  2. #2
    Idea Developer
    Join Date
    Sep 2000
    Location
    Bethlehem, PA
    Posts
    521
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can put this code between the body tags, and i think between the head tags, but not sure.
    Professional PHP programing / Hosting
    aim: downtoi3iz icq: 74637813

  3. #3
    SitePoint Member
    Join Date
    Sep 2000
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The best place to put that type of script is between the Head tags, as they are the first elements to be processed by your web-browser.

  4. #4
    SitePoint Zealot BobM's Avatar
    Join Date
    Jun 2000
    Location
    Tucson, AZ, USA
    Posts
    164
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think I was misunderstood. I know that the script goes between the head tags. What I meant was that I wanted to insert code into the above script that would place a cookie on the visitors computer that would make the pop-up window only pop-up once every 25 days or so.

    Anyhow I found a different script with the code already inserted, but thanks for the replies!
    Bob Messinger
    Movie-Fever.com - News, Reviews, Trailers..
    Movie Fever Forums - Visit and discuss movies with other fans!


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
  •