General Car Related Discussion. To discuss anything that is related to cars and automotive technology that doesnt naturally fit into another forum catagory.

Oit Petrururuccccci (or any web design gurus).....

Thread Tools
 
Search this Thread
 
Old 02-03-2005, 11:27 AM
  #1  
MadMac
15K+ Super Poster!!
Thread Starter
 
MadMac's Avatar
 
Join Date: Apr 2004
Location: Croydon
Posts: 16,505
Likes: 0
Received 0 Likes on 0 Posts
Default Oit Petrururuccccci (or any web design gurus).....

I'm using Dreamweaver to make a website.

Basicly at the header of each page is a picture of a car. I have been trying to work out how to make it randomly choose a different picture from a libary I have of them on line. So hopefully everytime the page is refreshed, it randomly picks out a new picture to put at the top of the page. But I'm not having much luck as I am shite at Java script.

I noticed you have managed to do it with the ads at the top of the page....

how did you do it?

If ya can help that would be soooper
Old 02-03-2005, 11:38 AM
  #2  
Billabong
PassionFord Post Whore!!

 
Billabong's Avatar
 
Join Date: May 2003
Location: Northants
Posts: 9,076
Likes: 0
Received 0 Likes on 0 Posts
Default

http://www.codeproject.com/jscript/banner_js.asp

http://www.brettb.com/js_banner_ad_rotator.asp
Old 02-03-2005, 11:44 AM
  #3  
frog
0-60 in 17 seconds (eek)
 
frog's Avatar
 
Join Date: Apr 2004
Location: Berkshire
Posts: 6,717
Likes: 0
Received 0 Likes on 0 Posts
Default

Stu,

if you have the same stuff at the top of every page, make sure you use the templates facility provided by dreamweaver. Saves copy/pasting the same code all over the place, and if you want to make a change, you make the change in the template and hey presto, change made everywhere
Old 02-03-2005, 02:47 PM
  #4  
MadMac
15K+ Super Poster!!
Thread Starter
 
MadMac's Avatar
 
Join Date: Apr 2004
Location: Croydon
Posts: 16,505
Likes: 0
Received 0 Likes on 0 Posts
Default

Mucho gracias people, very useful
Old 02-03-2005, 05:29 PM
  #5  
MadMac
15K+ Super Poster!!
Thread Starter
 
MadMac's Avatar
 
Join Date: Apr 2004
Location: Croydon
Posts: 16,505
Likes: 0
Received 0 Likes on 0 Posts
Default

The second one looks cool, but.... what do I have to modify to make it choose and image at random rather than in the order they are listed??

I told ya, I aint a clue

Code:
<script language="javascript"><!--
//JavaScript Banner Ad Rotator version 2.1 - last modified 16 November 2000
//Obtained from http://www.brettb.com/js_banner_ad_rotator.asp

//User defined variables - change these variables to alter the behaviour of the script
var ImageFolder = "images"; //Folder name containing the images
var ImageFileNames = new Array('AmazonAd1_anim.gif', 'ASPDocumentationToolBannerAd3.gif', 'AmazonAd2_anim.gif', 'WinnershTriangleWebSolutions_BannerAd.gif'); //List of images to use
var ImageURLs = new Array('http://www.amazon.com/exec/obidos/redirect?tag=brettbcom&path=subst/home/home.html', 'http://winnershtriangle.com/w/Products.ASPDocumentationTool.asp', 'http://www.amazon.com/exec/obidos/redirect?tag=brettbcom&path=subst/home/home.html', 'http://www.winnershtriangle.com/w/'); //List of hyperlinks associated with the list of images
var DefaultURL = 'http://www.amazon.com/exec/obidos/redirect?tag=brettbcom&path=subst/home/home.html'; //Default hyperlink for the Banner Ad
var DisplayInterval = 5; //Number of seconds to wait before the next image is displayed
var TargetFrame = ""; //Name of the frame to open the hyperlink into

//Internal variables (do not change these unless you know what you are doing)
var IsValidBrowser = false;
var BannerAdCode = 0;
var BannerAdImages = new Array(NumberOfImages);
var DisplayInterval = DisplayInterval * 1000;
var NumberOfImages = ImageFileNames.length;

//Add a trailing forward slash to the ImageFolder variable if it does not already have one
if (ImageFolder.substr(ImageFolder.length - 1, ImageFolder.length) != "/" && ImageFolder != "") { ImageFolder += "/";
}

if (TargetFrame == '') {
var FramesObject = null;
} else {
var FramesObject = eval('parent.' + TargetFrame);
}

//Function runs when this page has been loaded and does the following:
//1. Determine the browser name and version  (since the script will only work on Netscape 3+ and Internet Explorer 4+).
//2. Start the timer object that will periodically change the image displayed by the Banner Ad.
//3. Preload the images used by the Banner Ad rotator script
function InitialiseBannerAdRotator() {

//Determine the browser name and version
//The script will only work on Netscape 3+ and Internet Explorer 4+
var BrowserType = navigator.appName;
var BrowserVersion = parseInt(navigator.appVersion);

if (BrowserType == "Netscape" && (BrowserVersion >= 3)) {
IsValidBrowser = true;
}

if (BrowserType == "Microsoft Internet Explorer" && (BrowserVersion >= 4)) {
IsValidBrowser = true;
}

if (IsValidBrowser) {
TimerObject = setTimeout("ChangeImage()", DisplayInterval);
BannerAdCode = 0;

for (i = 0; i < NumberOfImages; i++) {
BannerAdImages[i] = new Image();
BannerAdImages[i].src = ' ' + ImageFolder + ImageFileNames[i];
}

}

}

//Function to change the src of the Banner Ad image
function ChangeImage() {

if (IsValidBrowser) {
BannerAdCode = BannerAdCode + 1;

if (BannerAdCode == NumberOfImages) {
BannerAdCode = 0;
}

window.document.bannerad.src = BannerAdImages[BannerAdCode].src;
TimerObject = setTimeout("ChangeImage()", DisplayInterval);
}
}

//Function to redirect the browser window/frame to a new location,
//depending on which image is currently being displayed by the Banner Ad.
//If Banner Ad is being displayed on an old browser then the DefaultURL is displayed
function ChangePage() {

if (IsValidBrowser) {

if (TargetFrame != '' && (FramesObject)) {
FramesObject.location.href = ImageURLs[BannerAdCode];
} else {
document.location = ImageURLs[BannerAdCode];
}

} else if (!IsValidBrowser) {
document.location = DefaultURL;
}

}
// --></script>
Anyone got any ideas?
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
tonicosworth
Ford Escort RS Cosworth
3
31-10-2015 08:40 AM
oilman
Trader Parts for Sale.
10
23-09-2015 07:32 PM
Glenn_
General Car Related Discussion.
7
18-09-2015 02:27 PM
RSmark84
General Car Related Discussion.
19
13-09-2015 01:29 PM



Quick Reply: Oit Petrururuccccci (or any web design gurus).....



All times are GMT. The time now is 10:03 AM.