I have two pop-under advertisement code which runs by clicking anywhere on my WordPress website and I want to first run one script and then, after one pop-under will open, on second click of same user, I want second pop-under to be opened. How can I do this on my WordPress website? Here is pop-under codes
<script type="text/javascript">
var _pop = _pop || [];
_pop.push(['siteId', 1205741]);
_pop.push(['minBid', 0.000000]);
_pop.push(['popundersPerIP', 0]);
_pop.push(['delayBetween', 0]);
_pop.push(['default', false]);
_pop.push(['defaultPerDay', 0]);
_pop.push(['topmostLayer', false]);
(function() {
var pa = document.createElement('script'); pa.type = 'text/javascript'; pa.async = true;
var s = document.getElementsByTagName('script')[0];
pa.src = '//c1.popads.net/pop.js';
pa.onerror = function() {
var sa = document.createElement('script'); sa.type = 'text/javascript'; sa.async = true;
sa.src = '//c2.popads.net/pop.js';
s.parentNode.insertBefore(sa, s);
};
s.parentNode.insertBefore(pa, s);
})();
</script>
<script type="text/javascript">
var uid = '101325';
var wid = '215567';
</script>
<script type="text/javascript" src="http://cdn.popcash.net/pop.js"></script>
Usually, you would consult popads.net if they provide a callback on the event of a pop, and add code of the second popup inside that callback.
But since the second code is synchronous, there is no way to put it in a callback, so this is impossible.
It has a chance to work in the reverse order of pops: you can bind a function to the “click” event of “body” element, and put the code of popads.net there.
I.e., somethinkg like: