Run javascript after other javascript runs on WordPress -


i have 2 pop-under advertisement code runs clicking anywhere on wordpress website , want first run 1 script , then, after 1 pop-under open, on second click of same user, want second pop-under opened. how can on wordpress website? here 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, consult popads.net if provide callback on event of pop, , add code of second popup inside callback.

but since second code synchronous, there no way put in callback, impossible.

it has chance work in reverse order of pops: can bind function "click" event of "body" element, , put code of popads.net there.

i.e., somethinkg like:

<script type="text/javascript"> var uid = '101325'; var wid = '215567'; </script> <script type="text/javascript" src="http://cdn.popcash.net/pop.js"></script>  <script> $( "body" ).bind( "click", function() {   var _pop = _pop || [];   _pop.push(['siteid', 1205741]);   _pop.push(['minbid', 0.000000]);   .   .   . }); </script> 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -