Reply
Random banner
Old 07-14-2005, 03:44 PM Random banner
Junior Talker

Posts: 1
hi, on my page i'd like my topbanners to load random on each page. I mean that if i open index, banner1 loads and when I press "Update" maybe banner3 loads.
Do any of you know the code for that?

I hope you got what i ment.
Nexon is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 07-15-2005, 12:18 AM
Kaiman's Avatar
Extreme Talker

Posts: 237
Nexon,

Try searching Hotscripts for Banner Rotation scripts. I have seen them done with PHP, Java, and other server sided languages but not with Javascript, although I believe it should be possible.

If Hotscripts doesn't have what your looking for, try using Google.

Kaiman

Website Design and Hosting - Glenwood Springs, CO
Storm King Computer Consulting

P.S. I don't know what kind of web hosting you have but I just noticed that CPanel (Linux/Unix online webhosting control panel) has a built in script called Entropy Banner that may be something like what you are looking for.

Last edited by Kaiman : 07-15-2005 at 12:22 AM.
Kaiman is offline
Reply With Quote
View Public Profile
 
Old 07-15-2005, 08:20 AM
onlyplace4's Avatar
Extreme Talker

Posts: 159
Location: Skegness, Lincolnshire, England
I have a JavaScript banner rotator on my site that uses a .js file to store the details of each banner, and then a function to select a random banner. The essential basics of the function are shown below:

Code:
function banner() {
	which = Math.random();
	which = Math.round(which*howmany);
	document.images['banner'].src = urls[which];
}
The variable howmany is stored in the .js file with the url information and is simply a howmany = urls.length-1; statement (the array that the urls are stored it is called urls).

Hope that is of some help.
onlyplace4 is offline
Reply With Quote
View Public Profile Visit onlyplace4's homepage!
 
Old 07-15-2005, 09:20 AM
Unknown.

Posts: 1,693
This should do what you want..

HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
<!--

function getrandbanner() {

var imgs = new Array();

imgs[0] = 'banner1.gif';
imgs[1] = 'banner2.gif';
imgs[2] = 'banner3.gif';
imgs[3] = 'banner4.gif';

var p = imgs.length;

var randimg = Math.round(Math.random()*(p-1));

document.getElementById("randimg").src= imgs[randimg];

}

//-->
</script>
</head>

<body onload="getrandbanner();">
<img src="" alt="" id="randimg" />
</body>
</html>
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Random banner
 

Thread Tools

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13726 seconds with 12 queries