• View our reviews on Hot Scripts
  • JS Tutorial

Recent Comments

Powered by Disqus

Back to articles

Display pop under advertisments using javascript

Pop under class allows you to implement pop under advertising to your website.

You can customize probability of ads to appear, time for how long to show advertisement. It is possible to add multiple advertisments, each advertisment will have same probability of appearing in pop under.

There is also an option to mark users who saw advertisement for specified period of time, so they won't be bothered with pop under advertisements during that specified period.

Package contains popunder.js and popunder.packed.js (packed javascript) and example file.



Example codes

    <h1>Main website content</h1>
    Some text and notext
    <p>Text in paragraph</p>
<script type="text/javascript" src="./popunder.js" ></script>
<script type="text/javascript">
var pop = new popunder({
    //seconds to show advertisment
    seconds: 30,
    //allow visitors to skip ads
    allowSkip: true,
    //possibility of ads to show up
    probability: 20,
    //mark users who saw ad
    markUser: true,
    //force redirecting
    forceRedirect: false,
    //show open in new window link
    openLink: true,
    //period of time in seconds
    //for how long marked users won't see ads
    markPeriod: 0,
    //Open in new window text
    openText: "Open in new window",
    //text before advertisment title
    beforeTitleText: "Advertisment:", 
    //text after seconds countdown
    secondsLeftText: "seconds left", 
    //text for redirecting
    redirectingText: "Redirecting", 
    //text for waiting
    waitingText: "Waiting for page to load", 
    //text for skip link
    skipText: "Continue to page",
    //callback on ad showing up
    onStart: null,
    //callback when user skips ad
    onSkip: null,
    //callback when ad finished to show
    onEnd: null,
    //background color of wrapper
    backgroundColor : "#fff"
pop.add("","Javascript classes", "1");
        "EasyChart class", "2");;

Examples in action

Example scripts provided with package in action:

Method list


Back to method list

Method namenew popunder(config)
DescriptionCreate popunder instance
Input parameters

json config - chart configuration:

  • int seconds - how long to show an advertisment in seconds (default: 30)
  • bool allowSkip - allow visitors to skip advertisment without waiting specified amount of time (default: true)
  • int probability - probability in percents of advertisments to appear to visitor (default: 20)
  • bool markUser - mark visitors who saw advertisment using cookies, ads won't appear to marked visitors (default: true)
  • bool forceRedirect - redirect users automatically, when timer expires(default: false)
  • bool openLink - Provide option to open link in new window, when timer expires and redirection is not forced(default: true)
  • int markPeriod - for how long in seconds to mark visitors, who saw advertisment, ads won't appear to marked visitors (default: 1 day)
  • string openText - text to show for open in new window link (default: "Open in new window")
  • string beforeTitleText - text to show before provided advertisment title (default: "Advertisment:")
  • string secondsLeftText - text which appears after countdown of seconds (default: "seconds left")
  • string redirectText - text which appears when advertisment is redirecting (default: "Redirecting")
  • string waitingText - text which appears while advertisment is loading (default: "Waiting for page to load")
  • string skipText - text which appears on skip link (default: "Continue to page")
  • function onStart - callback function which fires when advertisment is starting to load, callback function receives same parameters you provided to add function (default: none)
  • function onSkip - callback function which fires when visitor pressed skip link, callback function receives same parameters you provided to add function (default: none)
  • function onEnd - callback function which fires when advertisment countdown reached 0, callback function receives same parameters you provided to add function (default: none)
  • string backgroundColor - background color of popunder wrapper (default: "#FFF")

Add advertisment for popunder

Back to method list

Method nameadd(link, title, id)
DescriptionAdd advertisment to pop under which might appear to visitor. The values you provide here will be passed to a callback functions, so you\'ll know which of all advertisments was showed to visitor
Input parameters

string link - link to a website

string title - Title of advertisment

string id - identifier for an advertisment, for you to keep track of which advertisments showed up

Show advertisment

Back to method list

Method nameshow()
DescriptionInvokes method which calculates a chance if advertisment should appear using probability provided in configuration

Latest changes

  • 29. March, 2012 - Added option to configure force redirection and provide link to open in new window

You may also be interested in:

Powered by

blog comments powered by Disqus