javascript help plz
4 posters
Page 1 of 1
javascript help plz
can anyone tell me why this code wont work in my links widgit? but will work in a notepad file. if it can be fixed to work plz tell me how it can be optimized i got it off a code generator called HTML BASIX. its supposed to be a img/link rotator
heres the code
heres the code
- Code:
<script type="text/javascript">
<!-- Begin
rnd.today=new Date();
rnd.seed=rnd.today.getTime();
function rnd() {
rnd.seed = (rnd.seed*9301+49297) % 233280;
return rnd.seed/(233280.0);
};
function rand(number) {
var result = Math.ceil(rnd()*number);
if (!result)result++;
return result
};
var ad_cnt1 = 6;
var ad1 = rand(ad_cnt1);
var link1;
var adBanner1;
var width1
var height1
if (ad1==1) {
link1="http://techzone.forumpro.eu";
adBanner1="http://i701.photobucket.com/albums/ww19/techzo
ne_bucket/mini-banner.gif";
width1="120";
height1="80";
alt1="Techzone";
}
if (ad1==2) {
link1="http://www.archonrpg.com/";
adBanner1="http://www.archonrpg.com/media/waffleed.ico";
width1="120";
height1="80";
alt1="Waffle";
}
if (ad1==3) {
link1="http://www.petitionspot.com/petitions/SaveSGA/";
adBanner1="http://i652.photobucket.com/albums/uu241/rouge
wraith/SGA-1.jpg";
width1="120";
height1="80";
alt1="SaveSGA";
}
if (ad1==4) {
link1="http://www.forumotion.com/";
adBanner1="http://www.illiweb.com/fa/banner/en/banner5.pn
g";
width1="120";
height1="80";
alt1="free forum";
}
if (ad1==5) {
link1="http://yoursmiles.org/";
adBanner1="http://yoursmiles.org/img/sbutton.gif";
width1="120";
height1="80";
alt1="Free smilies";
}
if (ad1==6) {
link1="http://www.newgrounds.com/refer/rougewraith";
adBanner1="http://img.ngfiles.com/fan-net/Noob-
Antichrist2.gif";
width1="120";
height1="80";
alt1="Newgrounds";
}
document.write('<center><a href="' + link1 + '"
target="_top">');
document.write('<img src="' + adBanner1 + '" width=' +
width1 + ' height=' + height1 + ' border=0 alt="' + alt1
+ '"></a>');
document.write('</center>');
// End -->
</SCRIPT>
Last edited by Rougewraith on July 12th 2009, 4:47 am; edited 1 time in total
Re: javascript help plz
is there anyone who can help me? i want to show all of these links its just i have alot and i dnt want to have them all there at once
Re: javascript help plz
This version of your affiliates-banner-rotator will work. Pause is set to 5 seconds: ("cycle1()",5000)
Since there are only 6... All at once (in a row) looks OK
- Code:
<script type="text/javascript">
var imgs1 = new Array("http://i701.photobucket.com/albums/ww19/techzone_bucket/mini-banner.gif","http://www.archonrpg.com/media/waffleed.ico","http://i652.photobucket.com/albums/uu241/rougewraith/SGA-1.jpg","http://www.illiweb.com/fa/banner/en/banner5.png","http://yoursmiles.org/img/sbutton.gif","http://img.ngfiles.com/fan-net/Noob-Antichrist2.gif");
var lnks1 = new Array("http://techzone.forumpro.eu","http://www.archonrpg.com/","http://www.petitionspot.com/petitions/SaveSGA/","http://www.forumotion.com/","http://yoursmiles.org/","http://www.newgrounds.com/refer/rougewraith");
var alt1 = new Array("Techzone","Waffle","SaveSGA","Free Forum","Free smilies","Newgrounds");
var currentAd1 = 0;
var imgCt1 = 6;
function cycle1() {
if (currentAd1 == imgCt1) {
currentAd1 = 0;
}
var banner1 = document.getElementById('adBanner1');
var link1 = document.getElementById('adLink1');
banner1.src=imgs1[currentAd1]
banner1.alt=alt1[currentAd1]
document.getElementById('adLink1').href=lnks1[currentAd1]
currentAd1++;
}
window.setInterval("cycle1()",5000);
</script>
<a href=""http://techzone.forumpro.eu"" id="adLink1" target="_blank">
<img src="http://i701.photobucket.com/albums/ww19/techzone_bucket/mini-banner.gif" id="adBanner1" border="0" width="120" height="80"></a>
Since there are only 6... All at once (in a row) looks OK
- Code:
<div align="center">
<a href="http://techzone.forumpro.eu"><img src="http://i701.photobucket.com/albums/ww19/techzone_bucket/mini-banner.gif" alt="Techzone" title="Techzone" width="90" height="50" /></a> <a href="http://www.archonrpg.com/"><img src="http://www.archonrpg.com/media/waffleed.ico" border="0" alt="Waffle" title="Waffle" width="90" height="54" /></a> <a href="http://www.petitionspot.com/petitions/SaveSGA/"><img src="http://i652.photobucket.com/albums/uu241/rougewraith/SGA-1.jpg" alt="SaveSGA title="SaveSGA" width="90" height="50" /></a> <a href="http://www.forumotion.com/"><img src="http://www.illiweb.com/fa/banner/en/banner5.png" alt="free forum" title="forumotion.com" width="90" height="50" /></a> <a href="http://yoursmiles.org/"><img src="http://yoursmiles.org/img/sbutton.gif" alt="Free Smilies" title="Free Smilies" width="90" height="50" /></a> <a href="http://www.newgrounds.com/refer/rougewraith"><img src="http://img.ngfiles.com/fan-net/Noob-Antichrist2.gif" alt="Free Smilies" title="Free Smilies" width="90" height="50" /></a></div><br />
Re: javascript help plz
Since this thread is marked solved, I will lock this thread.
Sanket
Sanket
Sanket- ForumGuru
- Posts : 48766
Reputation : 2830
Language : English
Location : Mumbai
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum