Script Categories













Messages >>> Favorite Banner.

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

Add the below code to the <body> section of your page:

<script language="javascript" type="text/javascript">
/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- 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("../imagesJSF/OverviewFuncVars.gif",
                        "http://www.yaldex.com/JSFactory_Pro.htm",
                        "Best JavaScript Editor!",
                        10);
banners[1] = new banner("../imagesJSF/OverviewHigMatchingBrace.gif",
                        "http://www.yaldex.com/JSFactory_Pro.htm",
                        "Highlighting matching curly braces",
                        30);
banners[2] = new banner("../imagesJSF/OverviewIntelFunc.gif",
                        "http://www.yaldex.com/JSFactory_Pro.htm",
                        "Type-in templates",
                        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 + "'  BORDER=0 ALT='" + banners[i].alt + "'></A>");
return banners[i];
break;
      }
   }
}
//  End -->
</script>
<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>

JavaScript Editor Get Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.



Code was highlighted by 1st JavaScript Editor (The Best JavaScript Editor!).

http://www.cashadvance-loans.net/connecticut/cash-advance-shelton-ct/


©