View Full Version : rotating banner script
fire site
08-23-2002, 07:28 PM
Hello:
I am looking for a rotating banner script that will work with microsoft front page 2000. I have tried many scripts but somehow cannot get it right. any help will be greatly appreciated.
Does your server support any server side languages such as Perl or PHP?
Paul
Michael
08-30-2002, 02:57 PM
do you mean you want a script which is like banner script so that you can run a banner exchange, or do you mean you want s script which rotate your banner on your web page that everytime when a visitor is visiting the page, the banner will change?
fire site
08-30-2002, 04:11 PM
I am looking for a script that will randomly rotate a bunch of banners on my site. so each time a page is opened the banner will change. thanks in advance.
I have tried a couple of different scripts but for some reason they will not work with frontpage
jollyfactory
08-30-2002, 09:24 PM
you need to have some sort of access to another programming language like perl, php, asp and for many of the banner rotation scripts I've used, they mostly require ssi
I do not think the problems lie within frontpage
mikeyp
08-31-2002, 08:46 PM
aren't there banner rotators in javascript?
jollyfactory
08-31-2002, 11:20 PM
Originally posted by jollyfactory
you need to have some sort of access to another programming language like perl, php, asp and for many of the banner rotation scripts I've used, they mostly require ssi
I do not think the problems lie within frontpage
yes but it is better to have a server side driven rotator.. this gives you more security, more functions and more control
If you want to go for a simple rotator, by all means, use a javascript rotator
Michael
09-02-2002, 12:05 AM
I am sure that there is a Javascript which can do this trick, I made 2 scripts here and you can customize the way you want!
Script 1 -- Banner rotate script when everytime the page is load, the banner rotates!
put this script in <body></body> section
<script language="Javascript">
<!--
var core = 0;
link = new Array(
"http://www.yahoo.com",
"http://www.pokemon.com",
"http://www.php.net"
);
image = new Array(
"yahoo.jpg",
"pokemon.jpg",
"php.jpg"
);
text = new Array(
"Yahoo",
"Pokemon",
"PHP"
);
var time = new Date();
var core = time.getSeconds() % image.length;
var ranlink = link[core];
var ranimage = image[core];
var rantext = text[core];
document.write('<a href=\"' +ranlink+ '\"><img src=\"'+ranimage+'\" border="0" alt=\"'+rantext+'\"></a>');
//-->
</SCRIPT>
Link array stores the information of the url of the banner
image array stores the banners
text array stores the alternative text when you mouseover it
Script 2 --- Banner rotate script that rotates banners every X seconds!
put this script in <head>/head>
<script language="Javascript">
<!--
var date = 0;
var number = 0;
function rotate()
{
image = new Array()
image[0]=new Image()
image[0].src="yahoo.jpg",
image[1]=new Image()
image[1].src="pokemon.jpg",
image[2]=new Image()
image[2].src="php.jpg"
var time = new Date();
document.banner.src=image[number].src
if(number ==2 )
number=0
else
number++
setTimeout("rotate()",3000)
}
function linktoweb()
{
link = new Array(
"http://www.yahoo.com",
"http://www.pokemon.com",
"http://www.php.net"
);
window.location.href=link[number]
}
//-->
</SCRIPT>
change <body> into <body onload="rotate()">
put this script in <body></body>
<a href ="javascript:linktoweb()">
<IMG NAME="banner"
BORDER=0
HEIGHT=60
WIDTH=468
SRC="PChome.jpg"></a>
and it should be self-explanatory
hope this helps!
jollyfactory
09-04-2002, 02:05 AM
hey Micheal... nice work with the javascript
Hey I was just wondering why you included
the code
var time = new Date();
var core = time.getSeconds() % image.length;
I am not familiar with that code, when I took it out of the script, it worked perfectly fine, I was just wondering what purpose it served.. thanks
Michael
09-04-2002, 01:14 PM
I use the code to randomly choose what banner to display
first I declare "time" a date object, then use getSeconds to get a value from 1 to 60, then I declare "image" as an array object, then use image.length to get the number of images in this array, and distribute them evenly with "%", "%" is mod, it returns the remainder, for example, 7 % 2 will return 1, 8 % 5 will return 3
that's how it works!
jollyfactory
09-05-2002, 05:43 AM
nice.. I understand now :)
Spiritmaker
12-05-2002, 08:02 PM
Hi, just implemented your script! Works great thanks!
One thing though, I am using IE and the rotating worked but when I click on the link it didn't work. then noticed what the problem was, had to change:
<a href ="java script:linktoweb()">
to:
<a href ="javascript:linktoweb()">
Thanks again!!
petervazed
12-12-2002, 05:10 AM
Originally posted by Spiritmaker
had to change:
<a href ="java script:linktoweb()">
to:
<a href ="javascript:linktoweb()">
Yes... it is this forum what changes javascript
used in a code to java script.
Safety correction, so the script cannot be executed on the forum.
:rocker:
Hi,
The Javascripts posted above are excellent. Does anyone know how to modify the code of script 1 so that the banner is displayed in the middle of the page. When I tried the script images are displayed to the left. I am not familiar with Javascript.
Many thanks.
Regards,
BSR
Jokerman
03-22-2003, 11:00 PM
Script 1:
Change this line...
document.write('<a href=\"' +ranlink+ '\"><img src=\"'+ranimage+'\" border="0" alt=\"'+rantext+'\"></a>');
to
document.write('<center><a href=\"' +ranlink+ '\"><img src=\"'+ranimage+'\" border="0" alt=\"'+rantext+'\"></a></center>');
Script 2:
All you are doing is changing the image with javascript.
So place <center></center> around the image.
<center>
<a href ="java script:linktoweb()">
<IMG NAME="banner"
BORDER=0
HEIGHT=60
WIDTH=468
SRC="PChome.jpg"></a></center>
Hi Jokerman,
Thank you for your help. Much appreciated.
Regards,
BSR
vBulletin® v3.6.7, Copyright ©2000-2010, Jelsoft Enterprises Ltd.