JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 27th, 2003, 05:04 PM
sammy sammy is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 1 sammy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Angry Randombanners please help

Help! I'm trying to use this javascript for random banners as a separate file so I don't have to edit everypage when I come to change the banners. It's not working. Does anyone know why?

// a random banner generator
function randomBanner()
{var bannerImage=new Array()
// location of images in this array
bannerImage[1]="http://www.dgm2.com\/merchants\/boys\/mogo_banner_sexy.gif?Time=19:51:12"
bannerImage[2]="http://www.simplytrains.com\/pages\/assets\/banners\/tymeg.gif"
bannerImage[3]="http://www.simplytrains.com\/pages\/assets\/banners\/movietrak.gif"
var bannerLink=new Array()
// text
for pics goes here
bannerLink[1]="<a href=\"http:\/\/www.dgm2.com/m/boys/b.asp?A=3876&I=278\""
bannerLink[2]="<a href=\"http:\/\/www.tymeg.co.uk\""
bannerLink[3]=\"http:\/\/www.dgm2.com/m/movie/b.asp?A=3876&I=1433\""var getRan=Math.floor(Math.random()*bannerImage.length )
if (getRan==0)
getRan=1
document.write(''+bannerLink[getRan]+'target=\"_blank\"><img src=\"'+bannerImage[getRan]+'" alt=\"Click here to visit our
sponsor.\" title=\"Click here to visit our sponsor.\" width=\"468\" height=\"60\" border=\"0\" style=\"margin:
0px;\"/><\/a>')
}

Reply With Quote
  #2  
Old January 27th, 2003, 10:58 PM
meth meth is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 8 meth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
here's a different method...

Code:
<HTML>
<HEAD>
	<TITLE>Random Image</TITLE>
	<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
	<!-- Hide script from old browsers

	myPix = new Array("images/redBanner.gif","images/blueBanner.gif","images/greenBanner.gif")
	imgCt = myPix.length 

	function choosePic() {
		if (document.images) {
			randomNum = Math.floor((Math.random() * imgCt))
			document.myPicture.src = myPix[randomNum]
		}
	}

	// End hiding script from old browsers -->
	</SCRIPT>	
</HEAD>
<BODY BGCOLOR="WHITE" onLoad="choosePic()">
<IMG SRC="images/spacer.gif" WIDTH="400" HEIGHT="75" NAME="myPicture" ALT="some image">
</BODY>
</HTML>

Reply With Quote
  #3  
Old January 28th, 2003, 12:28 AM
Taelo Taelo is offline
5B's
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: PC, FL
Posts: 366 Taelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 30 m 59 sec
Reputation Power: 16
I use this for my logo rotation,..use it if you like it

Code:
		<a href="newz.php">
		<script type="text/javascript">
		<!-- //
		var numOfImages = 5 ;
		var randomnumber = Math.random() ;
		var rand_img = Math.round( (numOfImages-1) * randomnumber) + 1 ;
		var logo = new Array();
		logo[1] = "images/logo/logo1.gif";
		logo[2] = "images/logo/logo2.gif";
		logo[3] = "images/logo/logo3.gif";
		logo[4] = "images/logo/logo4.gif";
		logo[5] = "images/logo/logo5.gif";

		var randomLogo = logo[rand_img];

		document.write("<img src='"+randomLogo+"' border=0>")
		//-->
		</script></a>
__________________
-- Jason

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Randombanners please help


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap