netvillage Posted June 24, 2017 Report Posted June 24, 2017 It seemed to be a popular question on here but no solution, so I came up with something that seems to work pretty good. It uses a few jquery lines and doesn't use iframes or force a page refresh. Enjoy! <div id="myad"><ins data-revive-zoneid="2" data-revive-id="123456789"></ins></div> <div id="adScript"><script async src="http://xxxxx/www/delivery/asyncjs.php"></script></div> <button type="button" onclick="rotateAd('myad')">Rotate Ad</button> <script> function rotateAd(addiv) { // Remove old ad $( "#"+addiv ).empty(); $( "#adScript" ).empty(); window.reviveAsync={}; // Create new ad // <ins> element var ins = document.createElement('ins'); ins.setAttribute('data-revive-zoneid', '2'); ins.setAttribute('data-revive-id', 'de77d907e60f2f4544b2c1842c4e97ea'); document.getElementById(addiv).appendChild(ins); // <script> element var s = document.createElement("script"); s.type = "text/javascript"; s.src = "xxxxxx/www/delivery/asyncjs.php"; s.innerHTML = null; document.getElementById("adScript").innerHTML = ""; document.getElementById("adScript").appendChild(s); } </script> Just noticed I should prob make a parm out of the zone id Oh I just used a button to test. The rotateAd should be on a timer of some sort Quote
netvillage Posted June 25, 2017 Author Report Posted June 25, 2017 Actually Here's the same improved a little bit. didn't need the separate DIV for script <div id="myad"></div> <button type="button" onclick="rotateAd('myad',2)">Rotate Ad</button> <script> function rotateAd(addiv,zone) { // Remove old ad $( "#"+addiv ).empty(); window.reviveAsync={}; // Create new ad // <ins> element var ins = document.createElement('ins'); ins.setAttribute('data-revive-zoneid', zone); ins.setAttribute('data-revive-id', 123456789'); document.getElementById(addiv).appendChild(ins); // <script> element var s = document.createElement("script"); s.type = "text/javascript"; s.src = "//xxxxr/www/delivery/asyncjs.php"; s.innerHTML = null; document.getElementById(addiv).appendChild(s); } </script> Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.