Results 1 to 4 of 4

Thread: Title: Interstitial Content Box "Don't show again" link

  1. #1
    Join Date
    Jun 2014
    Posts
    2
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Title: Interstitial Content Box "Don't show again" link

    1) Script Title: Interstitial Content Box (v1.1)

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...terstitial.htm

    3) Describe problem: I would love to be able to include an option on this script to continue displaying the ad once per browser session, but include an option for a site visitor to select "Don't show me this again." Since a cookie is already being used in this script, is there any way to add a link to not show again to that particular visitor for x number of days?

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    addition code in red

    Code:
    /////////////End of interstitialBox object declaration here ////////////////////////////////
    
    function getCookie(Name){
    var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
    if (document.cookie.match(re)) //if cookie found
    return document.cookie.match(re)[0].split("=")[1] //return its value
    return null
    }
    
    function setCookie(name, value, days){
    var expireDate = new Date()
    //set "expstring" to either an explicit date (past or future)
    if (typeof days!="undefined"){ //if set persistent cookie
    var expstring=expireDate.setDate(expireDate.getDate()+parseInt(days))
    document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; "+interstitialBox.cookiesetting[1]
    }
    else //else if this is a session only cookie setting
    document.cookie = name+"="+value+"; "+interstitialBox.cookiesetting[1]
    }
    
    
    var stitialvars=new Object() //temporary object to reference/ shorthand certain interstitialBox properties
    stitialvars.freqtype=interstitialBox.displayfrequency[0] //"chance" or "cookie"
    stitialvars.cookieduration=interstitialBox.displayfrequency[1] //"session" or int (integer specifying number of days)
    stitialvars.cookiename=interstitialBox.cookiesetting[0] //name of cookie to use
    
    
    if (stitialvars.freqtype=="chance"){ //IF CHANCE MODE
    if (Math.floor(Math.random()*interstitialBox.displayfrequency[1])==0)
    interstitialBox.launch=true
    }
    else if (stitialvars.freqtype=="cookie" && stitialvars.cookieduration=="session"){ //IF "SESSION COOKIE" MODE
    if (getCookie(stitialvars.cookiename+"_s")==null){ //if session cookie is empty
    setCookie(stitialvars.cookiename+"_s", "loaded")
    interstitialBox.launch=true
    }
    }
    else if (stitialvars.freqtype=="cookie" && typeof parseInt(stitialvars.cookieduration)=="number"){ //IF "PERSISTENT COOKIE" MODE
    if (getCookie(stitialvars.cookiename)==null || parseInt(getCookie(stitialvars.cookiename))!=parseInt(stitialvars.cookieduration)){ //if persistent cookie is empty or admin has changed number of days to persist from that of the stored value (meaning, reset it)
    setCookie(stitialvars.cookiename, stitialvars.cookieduration, stitialvars.cookieduration)
    interstitialBox.launch=true
    }
    }
    
    if (getCookie(stitialvars.cookiename)=='never'){
     setCookie(stitialvars.cookiename, "never",1000);
     interstitialBox.launch=false;
    }
    
    
    if (interstitialBox.launch)
    interstitialBox.initialize()
    to control

    Code:
    <input type="button" name="" value="Never Show" onclick="setCookie(stitialvars.cookiename, 'never',1000);" />
    <input type="button" name="" value="Cancel Never Show" onclick="setCookie(stitialvars.cookiename, 'never',-1);" />
    or to change the interstitial box

    Code:
    //3) HTML for the header bar portion of the interstitial box
    defineheader: '<div class="headerbar"><a href="#" onClick="javascript:interstitialBox.closeit(); return false"><img src="http://www.vicsjavascripts.org/StdImages/1.gif" style="border: 0;width:50px;" title="Close Box"/></a><input type="button" name="" value="Never Show" onclick="setCookie(stitialvars.cookiename, \'never\',1000);" /></div>',
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  3. The Following User Says Thank You to vwphillips For This Useful Post:

    coursons (06-24-2014)

  4. #3
    Join Date
    Jun 2014
    Posts
    2
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Thank you so much! This is fantastic! I just have a couple of simple follow up questions.

    1. In the js file, does the "1000" referenced in the 'never,1000' refer to how many days the cookie will prevent the ad from showing again?
    2. Is there a way I can make the "Never Show" box also close the ad when clicked?

  5. #4
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    1. In the js file, does the "1000" referenced in the 'never,1000' refer to how many days the cookie will prevent the ad from showing again?
    YES

    2. Is there a way I can make the "Never Show" box also close the ad when clicked?
    Code:
    defineheader: '<div class="headerbar"><a href="#" onClick="javascript:interstitialBox.closeit(); return false"><img src="http://www.vicsjavascripts.org/StdImages/1.gif" style="border: 0;width:50px;" title="Close Box"/></a><input type="button" name="" value="Never Show" onclick="setCookie(stitialvars.cookiename, \'never\',1000);interstitialBox.closeit();" /></div>',
    or in this part of the script

    Code:
    if (getCookie(stitialvars.cookiename)=='never'){
     setCookie(stitialvars.cookiename, "never",1000);
     interstitialBox.closeit();
     interstitialBox.launch=false;
    }
    Last edited by vwphillips; 06-25-2014 at 09:01 AM.
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  6. The Following User Says Thank You to vwphillips For This Useful Post:

    coursons (06-25-2014)

Similar Threads

  1. Interstitial Script Activated by button or link?
    By homersheineken in forum JavaScript
    Replies: 2
    Last Post: 12-22-2012, 06:22 PM
  2. Script Title: Interstitial Content Box (v1.1)
    By shakti007 in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 02-09-2012, 04:24 PM
  3. Replies: 1
    Last Post: 04-23-2010, 11:26 AM
  4. open Interstitial Content Box with a link?
    By badbandit in forum Dynamic Drive scripts help
    Replies: 3
    Last Post: 10-13-2007, 10:45 AM

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
  •