dynamically_not
03-15-2006, 06:24 PM
greetings all,
some help with this script would be appreciated;
Its a script that allows the rotation of banners on a webpage, .gif banners in my case, inserted into a table in an Iframe. This is a section of the code:
<SCRIPT LANGUAGE="javascript">
<!--
function banner(img_source,url,alt,chance) {
this.img_source = img_source;
this.url = url;
this.alt = alt;
this.chance = chance;
}
function display() {
with (this) document.write("<A HREF=" + url + "><IMG SRC='" + img_source + "' WIDTH=460 HEIGHT=115 BORDER=0 ALT='" + alt + "'></A>");
}
banner.prototype.display = display;
banners = new Array();
banners[0] = new banner("files/banner/0.gif",
"http://mysite/index.htm",
"",
sum_of_all_chances = 0;
for (i = 0; i < banners.length; i++) {
sum_of_all_chances += banners[i].chance;
}
function display_banner() {
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].img_source + "' WIDTH=460 HEIGHT=115 BORDER=0 ALT='" + banners[i].alt + "'></A>");
return banners[i];
break;
}
}
}
//-->
</SCRIPT>
My question is: how would i have the link open in the _parent (same window) when clicking the banner. Hope i make sense....
some help with this script would be appreciated;
Its a script that allows the rotation of banners on a webpage, .gif banners in my case, inserted into a table in an Iframe. This is a section of the code:
<SCRIPT LANGUAGE="javascript">
<!--
function banner(img_source,url,alt,chance) {
this.img_source = img_source;
this.url = url;
this.alt = alt;
this.chance = chance;
}
function display() {
with (this) document.write("<A HREF=" + url + "><IMG SRC='" + img_source + "' WIDTH=460 HEIGHT=115 BORDER=0 ALT='" + alt + "'></A>");
}
banner.prototype.display = display;
banners = new Array();
banners[0] = new banner("files/banner/0.gif",
"http://mysite/index.htm",
"",
sum_of_all_chances = 0;
for (i = 0; i < banners.length; i++) {
sum_of_all_chances += banners[i].chance;
}
function display_banner() {
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].img_source + "' WIDTH=460 HEIGHT=115 BORDER=0 ALT='" + banners[i].alt + "'></A>");
return banners[i];
break;
}
}
}
//-->
</SCRIPT>
My question is: how would i have the link open in the _parent (same window) when clicking the banner. Hope i make sense....