1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Please Help Edit this Javascript Code

Discussion in 'HTML & Website Design' started by kweliz, Feb 19, 2011.

  1. #1
    Hello, I am using a chunk of javascript code I found off google to create my own popunders for my website. It works fine except I cannot figure out how to edit the Pop Frequency. I believe it is set to 1 Day between popunders, and I would like to edit that into a set amount of hours. I'll paste the code below, I have tried changing the "stagedPopFrequency" variable to many things, but none have worked. Any help would be appreciated, thanks



    <SCRIPT LANGUAGE="JavaScript">
    // JavaScript Document
    var stagedPopFrequency = "1 Days";
    var stagedCookieName = "__name";

    if (!document.currentStage)
    document.currentStage = 0;
    document.currentStage++;

    if (document.currentStage == 1) {
    function stagedGetCookie(Name) {
    var search = Name + "=";
    var returnvalue = "";
    if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search);
    if (offset != -1) { // if cookie exists
    offset += search.length;
    // set index of beginning of value
    end = document.cookie.indexOf(";", offset);
    // set index of end of cookie value
    if (end == -1)
    end = document.cookie.length;
    returnvalue = unescape(document.cookie.substring(offset, end));
    }
    }
    return returnvalue;
    }

    function stagedSetCookie(Name, Value, Expire) {
    if (Expire != null) {
    var expireDate = new Date();
    expireDate.setDate(expireDate.getDate() + parseInt(Expire));
    document.cookie = Name+"="+Value+";path=/;expires=" + expireDate.toGMTString();
    } else {
    document.cookie = Name+"="+Value+";path=/";
    }
    }

    function stagedResetCookie(Name) {
    var expireDate = new Date();
    expireDate.setDate(expireDate.getDate() - 10);
    document.cookie = Name+"=;path=/;expires=" + expireDate.toGMTString();
    }

    function stagedPopUnder() {
    if (stagedGetCookie(stagedCookieName) == '') {
    var thisStage = 1;
    var stageFunc = eval('window.popUnderStage'+thisStage);
    if (stageFunc != undefined) {
    stageFunc();
    stagedSetCookie(stagedCookieName, thisStage + 1, stagedPopFrequency);
    }
    } else {
    var thisStage = parseInt(stagedGetCookie(stagedCookieName));
    var stageFunc = eval('window.popUnderStage'+thisStage);
    if (stageFunc != undefined) {
    stageFunc();
    stagedSetCookie(stagedCookieName, thisStage + 1, stagedPopFrequency);
    }
    }
    }

    function stagedAttachBody() {
    if (document.body) {
    if (document.all) {
    document.body.attachEvent('onclick', stagedPopUnder);
    } else {
    document.body.addEventListener('click', stagedPopUnder, false);
    }
    } else {
    setTimeout('stagedAttachBody()', 200);
    }
    } stagedAttachBody();
    }

    if( parseInt(navigator.appVersion) > 3 )
    {
    winWidth = screen.availWidth;
    winHeight = screen.availHeight;
    }
    else
    {
    winWidth = "1024";
    winHeight = "768";
    }

    var stagedTmpFunc = function() {
    var pu = window.open("http://LinkRemovedToAvoidSpam", "_blank", "width=" + winWidth + ",height=" + winHeight + ",scrollbars=1,resizable=1,menubar=1");
    pu.blur();
    window.focus();


    }
    eval('window.popUnderStage'+document.currentStage+' = stagedTmpFunc;');
    stagedTmpFunc = null;

    </script>
     
    kweliz, Feb 19, 2011 IP
  2. jawanda

    jawanda Peon

    Messages:
    151
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I don't know about the rest of the code, but to make your cookie expire after 24 hours, try this ... At the top where you have:

    var stagedPopFrequency = "1 Days";

    Change it to this

    var expDate = new Date();
    expDate.setHours( parseInt(expDate.getHours()) + 24 );
    var stagedPopFrequency = expDate();

    In theory that will make your cookies expire after 24 hours and thus the popup will be triggered once per day.

    -Phil
     
    jawanda, Feb 20, 2011 IP
  3. kweliz

    kweliz Member

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    thanks for the response, but It didn't work. I changed the 24 to 1 and made var stagedPopFrequency = expDate(); into var stagedPopFrequency = "expDate()";
    Because it wouldn't launch without the quotes. I waited more then an hour and tried again and it wont launch again, any ideas why?
     
    kweliz, Feb 20, 2011 IP