favorite banner




JavaScript Source Code 3000: Messages: Favorite Banner








































Favorite Banner







Display banners while controlling how often they appear. Great for displaying a preferred banner over others!















JavaScript Source Code 3000: Messages: Favorite Banner
Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as Note Pad or Simple Text) and save (Control-s or Command-s). The script is yours!!!





    





<!-- TWO STEPS TO INSTALL FAVORITE BANNER:

1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Rich Galichon (rich@galichon.net) -->
<!-- Web Site: http://www.galichon.net -->

<! >
<! >

<!-- Begin
function banner(imgSource,url,alt,chance) {
this.imgSource = imgSource;
this.url = url;
this.alt = alt;
this.chance = chance;
}
function dispBanner() {
with (this) document.write("<A HREF=" + url + "><IMG SRC='" + imgSource + "' WIDTH=468 HEIGHT=60 BORDER=0 ALT='" + alt + "'></A>");
}
banner.prototype.dispBanner = dispBanner;
banners = new Array();
banners[0] = new banner("http://www.galichon.net/images/banner/galichon_logo.jpg",
"http://www.galichon.net target='_blank'",
"Galichon Enterprises",
10);
banners[1] = new banner("http://imageserv.imgis.com/images/Ad13700St1Sz1Sq1_Ban1.gif",
"http://www.banner1-url-here.com target='_blank'",
"Description Here",
30);
banners[2] = new banner("http://imageserv.imgis.com/images/Ad13189St1Sz1Sq5_Ban10.gif",
"http://www.banner2-url-here.com target='_blank'",
"Description Here",
20);
///////////////////////////////////////////////////
// banners[x] = new banner(<banner source image>, // <url to link to when the banner is clicked>, // <alt> // <the chance this banner has in which to be randomly selected>);
// To increase the chance of a banner being randomly selected, increase it's corresponding // 'chance' property relative to the other banners.
///////////////////////////////////////////////////
sum_of_all_chances = 0;
for (i = 0; i < banners.length; i++) {
sum_of_all_chances += banners[i].chance;
}
function randomBanner() {
chance_limit = 0;
randomly_selected_chance = Math.round((sum_of_all_chances - 1) * Math.random()) + 1;
for (i = 0; i < banners.length; i++) {
chance_limit += banners[i].chance;
if (randomly_selected_chance <= chance_limit) {
document.write("<A HREF=" + banners[i].url + "><IMG SRC='" + banners[i].imgSource + "' WIDTH=468 HEIGHT=60 BORDER=0 ALT='" + banners[i].alt + "'></A>");
return banners[i];
break;
}
}
}
// End -->
</script>

</HEAD>

<!-- STEP TWO: Copy this code into the BODY of your HTML document -->

<BODY>

<SCRIPT LANGUAGE="JavaScript">

<! >
<! >

<!-- Begin
this_banner = randomBanner();
document.write("<br><br>This banner had a " + (this_banner.chance / sum_of_all_chances) * 100 + "% chance of being displayed"); // This line may be removed
// End -->
</script>



<!-- Script Size: 3.48 KB -->











Wyszukiwarka