Forum Moderators: open
<div class="banner">
<script language='JavaScript' type='text/javascript'>
<!--
if (!document.phpAds_used) document.phpAds_used = ',';
phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);
document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
document.write ("http://www.mydomain.com/asf/stats/adjs.php?n=" + phpAds_random);
document.write ("&what=zone:12&target=_blank");
document.write ("&exclude=" + document.phpAds_used);
if (document.referer)
document.write ("&referer=" + escape(document.referer));
document.write ("'><" + "/script>");
//-->
</script><noscript><a href='http://www.mydomain.com/asf/stats/adclick.php?n=a160758b' target='_blank'><img src='http://www.mydomain.com/asf/stats/adview.php?what=zone:12&n=a160758b' border='0' alt=''></a></noscript>
</div>
I'm really rubbish at js so I'm having a bit of trouble here, but I'm sure it's a piece of cake for you javascript people out there. Any ideas how to do this?
JS:
function rotateAds() {
if (!document.phpAds_used) document.phpAds_used = ',';
phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);
var r = (document.referer)? "&referer="+escape(document.referer) : "";
var b = document.getElementById("banner");
b.innerHTML = "";
var js = document.createElement("script");
js.type = "text/javascript";
js.src = "http://www.mydomain.com/asf/stats/adjs.php?n="+phpAds_random+"&what=zone:12&target=_blank&exclude=" +document.phpAds_used+r;
b.appendChild(js);
}
window.setTimeout("rotateAds()",30000);
This writes the no script in the div, which if there is no script, then it is never replaced. However, if script is running, then the function clears the previous contents of the div, then creates a new js link to create a new ad. The settimeout repeats this every 30 seconds...
- JS