Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

General discussion

Can someone help with a script that rotates a .sfw banner ad

Feb 18, 2008 6:07AM PST

below is the script I am using on my website in the top banner ad space. The ad rotates and works, but the WHOLE page refreshes every time the image rotates to the next. I am adding the code below. if someone can figure out how to stop the page from refreshing and only have the banner ad refresh, I would really appreciate it.

<center>
<div id="BannerSpace"></div>
</center>
<script language="JavaScript">
<!--
// Create arrays to contain all the values
// for links and image locations
var link = new Array
var image = new Array
//number of milliseconds between rotations
var refreshCount = 20000; // 20 seconds

link[0]="http://www.smsexpert.com/Products/Companion.aspx";
image[0]="http://www.blogcastrepository.com/ads/smsexpert/CompanionFlashBanner.swf";

link[1]="http://www.smsexpert.com/Products/ESD.aspx";
image[1]="http://www.blogcastrepository.com/ads/smsexpert/SelfServiceFlashBanner2.swf";

link[2]="http://www.smsexpert.com/Products/ESD.aspx";
image[2]="http://www.blogcastrepository.com/ads/smsexpert/SelfServiceFlashBanner.swf";

link[3]="http://www.smsexpert.com/Products/Companion.aspx";
image[3]="http://www.blogcastrepository.com/ads/smsexpert/CompanionFlashBanner2.swf";

var last_num = -1;
function setAdvertisement()
{
var random_num = image.length;
// Create a random number between 1 and last number
while (random_num > (image.length -1) || random_num == last_num)
random_num = (Math.round((Math.random()*(image.length-1))))

var str = "<a href='" + link[random_num] + "' target='_blank'><object onClick='javascript:window.open(\"" + link[random_num] + "\", \"_blank\");' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' id='BannerAd' width='468' height='60'><param name='movie' value='" + image[random_num] + "'><param name='bgcolor' value='#FFFFFF'><param name='quality' value='high'><param name='allowscriptaccess' value='samedomain'><embed type='application/x-shockwave-flash' pluginspage='http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' name='BannerAd' width='468' height='60' src='" + image[random_num] + "' bgcolor='#FFFFFF' quality='high' allowscriptaccess='samedomain'><noembed></noembed></embed></object></a>";

BannerSpace.innerHTML = str;
window.setTimeout(setAdvertisement, 20000);
}

setAdvertisement();
-->
</script>

Discussion is locked