Carousel for banners

L

Lloyd Codrington

I am building a site and have a few banners I wish to display. Can anyone
help me code a delay that would then load the next banner? Each banner code
is in HTML and includes a link to an external site.
 
J

Jose Carlos

Hi, Lloyd!
You can use this Javascript code for you carousel:

var lista = new Array('1.jpg', '2.jpg', '3.jpg' , '4.jpg');
var contador = 0;
var tiempo = 0;
var tempor = null;
function cambio(sen)
{
contador+= sen;
if (contador ==lista.length)
contador = lista.length-1;
else
if (contador < 0) contador = 0;
document.images.centro.src = lista[contador]
window.status="Imagen número "+contador
}
function reset()
{
contador = 0;
fin = false;
document.images.centro.src = lista[0]
}
function automat(seg)
{
tiempo = parseInt(seg);
reset();
window.status="Pase automático";
if (isNaN(tiempo) || tiempo <= 0)
alert("Error en el tiempo")
else
tempor = setTimeout("pasar()", tiempo)
}
function parar()
{
clearTimeout(tempor);
}
function pasar()
{
cambio(1);
if (contador < lista.length-1)
tempor = setTimeout("pasar()", tiempo)
}

Remember, you must include labels <script> and </script> in the beginning
and in the end of the code. I have made it for four images, but you can put
whatever you want.
Sorry, my english isn't very good...


"Lloyd Codrington" escribió:
 
L

Lloyd Codrington

Hi Jose,

Thanks for your solution but the script seems to be one for loading images
i.e. jpg, gif, wmfs' etc. What I need however is one that is capable of
loading HTML code such as the example below:

<a href="http://www.awine.co.uk/awclick.php?mid=435&linkid=7881&id=666"
target="_blank">
<img src="http://www.awine.co.uk/show.php?mid=435&linkid=7881&aid=666"
border="0" vspace="3"></a><br>

I have quite a few bits of code like this and was hopeing to save them as
individual files outside of the actual page to speed up loading. So I was
hoping any solution would call the file and execute the code in the page
being displayed.

Thanks again for the script you posted I know that will come in handy but it
is not exactly what I needed for this function.

All the best.

ps - Your English was fine.


Jose Carlos said:
Hi, Lloyd!
You can use this Javascript code for you carousel:

var lista = new Array('1.jpg', '2.jpg', '3.jpg' , '4.jpg');
var contador = 0;
var tiempo = 0;
var tempor = null;
function cambio(sen)
{
contador+= sen;
if (contador ==lista.length)
contador = lista.length-1;
else
if (contador < 0) contador = 0;
document.images.centro.src = lista[contador]
window.status="Imagen número "+contador
}
function reset()
{
contador = 0;
fin = false;
document.images.centro.src = lista[0]
}
function automat(seg)
{
tiempo = parseInt(seg);
reset();
window.status="Pase automático";
if (isNaN(tiempo) || tiempo <= 0)
alert("Error en el tiempo")
else
tempor = setTimeout("pasar()", tiempo)
}
function parar()
{
clearTimeout(tempor);
}
function pasar()
{
cambio(1);
if (contador < lista.length-1)
tempor = setTimeout("pasar()", tiempo)
}

Remember, you must include labels <script> and </script> in the beginning
and in the end of the code. I have made it for four images, but you can put
whatever you want.
Sorry, my english isn't very good...


"Lloyd Codrington" escribió:
I am building a site and have a few banners I wish to display. Can anyone
help me code a delay that would then load the next banner? Each banner code
is in HTML and includes a link to an external site.
 
J

Jose Carlos

That's right, Lloyd!
Here I am a new script that you can prove:
Copy&Paste the next block:
<td>
<div align="center">
<table border="0" cellspacing="0" cellpadding="0" width="96">
<tr>
<td width="94"><script language="JavaScript1.2">
<!--

var sliderwidth=500
var sliderheight=150
var slidespeed=5

var leftrightslide=new Array()
var finalslide=''
leftrightslide[0]='<a href="http://www.yomaster.galeon.com"
target="_blank"><img src="images/banner1.gif" border=1 alt="Clic aquí para
ver."></a>'
leftrightslide[1]='<a href="http://www.yomaster.galeon.com"
target="_blank"><img src="images/banner0.gif" border=1 alt="Clic aquí para
ver."></a>'
leftrightslide[2]='<a href="http://www.yomaster.galeon.com"
target="_blank"><img src="images/banner.gif" border=1 alt="Clic aquí para
ver."></a>'


var copyspeed=slidespeed
for (i=0;i<leftrightslide.length;i++)
finalslide=finalslide+leftrightslide+" "


if (document.all){
document.write('<marquee id="ieslider" scrollAmount=0
style="width:'+sliderwidth+'">'+finalslide+'</marquee>')
ieslider.onmouseover=new Function("ieslider.scrollAmount=0")
ieslider.onmouseout=new Function("if (document.readyState=='complete')
ieslider.scrollAmount=slidespeed")
}

function regenerate(){
window.location.reload()
}
function regenerate2(){
if (document.layers){
document.ns_slider01.visibility="show"
setTimeout("window.onresize=regenerate",450)
intializeleftrightslide()
}
if (document.all)
ieslider.scrollAmount=slidespeed
}

function intializeleftrightslide()
document.ns_slider01.document.ns_slider02.document.write('<nobr>'+finalslide+'</nobr>')
document. ns_slider01.document.ns_slider02.document.close()
thelength=document.ns_slider01.document.ns_slider02.document.width
scrollslide()
}

function scrollslide(){
if (document.ns_slider01.document.ns_slider02.left>=thelength*(-1)){
document.ns_slider01.document.ns_slider02.left-=slidespeed
setTimeout("scrollslide()",100)
}
else{
document.ns_slider01.document.ns_slider02.left=sliderwidth
scrollslide()
}
}
window.onload=regenerate2

//-->
</script>
<ilayer width=&{sliderwidth}; height=&{sliderheight};
name="ns_slider01" visibility=hide>
<layer name="ns_slider02" onMouseover="slidespeed=0;"
onMouseout="slidespeed=copyspeed">
</layer>
</ilayer>
<p align="center" style="margin-top: 0; margin-bottom:
0"> </td>
</tr>
</table>
</div>
</td>

Well,As you see, its contains the structure <a href="..."><img ...>, which
you can change.
I hope I have helped you this time..

"Lloyd Codrington" escribió:
Hi Jose,

Thanks for your solution but the script seems to be one for loading images
i.e. jpg, gif, wmfs' etc. What I need however is one that is capable of
loading HTML code such as the example below:

<a href="http://www.awine.co.uk/awclick.php?mid=435&linkid=7881&id=666"
target="_blank">
<img src="http://www.awine.co.uk/show.php?mid=435&linkid=7881&aid=666"
border="0" vspace="3"></a><br>

I have quite a few bits of code like this and was hopeing to save them as
individual files outside of the actual page to speed up loading. So I was
hoping any solution would call the file and execute the code in the page
being displayed.

Thanks again for the script you posted I know that will come in handy but it
is not exactly what I needed for this function.

All the best.

ps - Your English was fine.


Jose Carlos said:
Hi, Lloyd!
You can use this Javascript code for you carousel:

var lista = new Array('1.jpg', '2.jpg', '3.jpg' , '4.jpg');
var contador = 0;
var tiempo = 0;
var tempor = null;
function cambio(sen)
{
contador+= sen;
if (contador ==lista.length)
contador = lista.length-1;
else
if (contador < 0) contador = 0;
document.images.centro.src = lista[contador]
window.status="Imagen número "+contador
}
function reset()
{
contador = 0;
fin = false;
document.images.centro.src = lista[0]
}
function automat(seg)
{
tiempo = parseInt(seg);
reset();
window.status="Pase automático";
if (isNaN(tiempo) || tiempo <= 0)
alert("Error en el tiempo")
else
tempor = setTimeout("pasar()", tiempo)
}
function parar()
{
clearTimeout(tempor);
}
function pasar()
{
cambio(1);
if (contador < lista.length-1)
tempor = setTimeout("pasar()", tiempo)
}

Remember, you must include labels <script> and </script> in the beginning
and in the end of the code. I have made it for four images, but you can put
whatever you want.
Sorry, my english isn't very good...


"Lloyd Codrington" escribió:
I am building a site and have a few banners I wish to display. Can anyone
help me code a delay that would then load the next banner? Each banner code
is in HTML and includes a link to an external site.
 
L

Lloyd Codrington

Jose,
I am going to try it out in a moment and will let you know how I get on.
You worry about your English but it seems like your Java is up to speed.

Drop me and email as I may be able to put some freelance work your way if
you are interested. (e-mail address removed)

Thanks and I'm sure you have helped.

Lloyd Codrington - Bluespot Network Ltd


Jose Carlos said:
That's right, Lloyd!
Here I am a new script that you can prove:
Copy&Paste the next block:
<td>
<div align="center">
<table border="0" cellspacing="0" cellpadding="0" width="96">
<tr>
<td width="94"><script language="JavaScript1.2">
<!--

var sliderwidth=500
var sliderheight=150
var slidespeed=5

var leftrightslide=new Array()
var finalslide=''
leftrightslide[0]='<a href="http://www.yomaster.galeon.com"
target="_blank"><img src="images/banner1.gif" border=1 alt="Clic aquí para
ver."></a>'
leftrightslide[1]='<a href="http://www.yomaster.galeon.com"
target="_blank"><img src="images/banner0.gif" border=1 alt="Clic aquí para
ver."></a>'
leftrightslide[2]='<a href="http://www.yomaster.galeon.com"
target="_blank"><img src="images/banner.gif" border=1 alt="Clic aquí para
ver."></a>'


var copyspeed=slidespeed
for (i=0;i<leftrightslide.length;i++)
finalslide=finalslide+leftrightslide+" "


if (document.all){
document.write('<marquee id="ieslider" scrollAmount=0
style="width:'+sliderwidth+'">'+finalslide+'</marquee>')
ieslider.onmouseover=new Function("ieslider.scrollAmount=0")
ieslider.onmouseout=new Function("if (document.readyState=='complete')
ieslider.scrollAmount=slidespeed")
}

function regenerate(){
window.location.reload()
}
function regenerate2(){
if (document.layers){
document.ns_slider01.visibility="show"
setTimeout("window.onresize=regenerate",450)
intializeleftrightslide()
}
if (document.all)
ieslider.scrollAmount=slidespeed
}

function intializeleftrightslide(){
document.ns_slider01.document.ns_slider02.document.write('<nobr>'+finalslide+'</nobr>')
document. ns_slider01.document.ns_slider02.document.close()
thelength=document.ns_slider01.document.ns_slider02.document.width
scrollslide()
}

function scrollslide(){
if (document.ns_slider01.document.ns_slider02.left>=thelength*(-1)){
document.ns_slider01.document.ns_slider02.left-=slidespeed
setTimeout("scrollslide()",100)
}
else{
document.ns_slider01.document.ns_slider02.left=sliderwidth
scrollslide()
}
}
window.onload=regenerate2

//-->
</script>
<ilayer width=&{sliderwidth}; height=&{sliderheight};
name="ns_slider01" visibility=hide>
<layer name="ns_slider02" onMouseover="slidespeed=0;"
onMouseout="slidespeed=copyspeed">
</layer>
</ilayer>
<p align="center" style="margin-top: 0; margin-bottom:
0"> </td>
</tr>
</table>
</div>
</td>

Well,As you see, its contains the structure <a href="..."><img ...>, which
you can change.
I hope I have helped you this time..

"Lloyd Codrington" escribió:
Hi Jose,

Thanks for your solution but the script seems to be one for loading images
i.e. jpg, gif, wmfs' etc. What I need however is one that is capable of
loading HTML code such as the example below:

<a href="http://www.awine.co.uk/awclick.php?mid=435&linkid=7881&id=666"
target="_blank">
<img src="http://www.awine.co.uk/show.php?mid=435&linkid=7881&aid=666"
border="0" vspace="3"></a><br>

I have quite a few bits of code like this and was hopeing to save them as
individual files outside of the actual page to speed up loading. So I was
hoping any solution would call the file and execute the code in the page
being displayed.

Thanks again for the script you posted I know that will come in handy but it
is not exactly what I needed for this function.

All the best.

ps - Your English was fine.


Jose Carlos said:
Hi, Lloyd!
You can use this Javascript code for you carousel:

var lista = new Array('1.jpg', '2.jpg', '3.jpg' , '4.jpg');
var contador = 0;
var tiempo = 0;
var tempor = null;
function cambio(sen)
{
contador+= sen;
if (contador ==lista.length)
contador = lista.length-1;
else
if (contador < 0) contador = 0;
document.images.centro.src = lista[contador]
window.status="Imagen número "+contador
}
function reset()
{
contador = 0;
fin = false;
document.images.centro.src = lista[0]
}
function automat(seg)
{
tiempo = parseInt(seg);
reset();
window.status="Pase automático";
if (isNaN(tiempo) || tiempo <= 0)
alert("Error en el tiempo")
else
tempor = setTimeout("pasar()", tiempo)
}
function parar()
{
clearTimeout(tempor);
}
function pasar()
{
cambio(1);
if (contador < lista.length-1)
tempor = setTimeout("pasar()", tiempo)
}

Remember, you must include labels <script> and </script> in the beginning
and in the end of the code. I have made it for four images, but you can put
whatever you want.
Sorry, my english isn't very good...


"Lloyd Codrington" escribió:

I am building a site and have a few banners I wish to display. Can anyone
help me code a delay that would then load the next banner? Each banner code
is in HTML and includes a link to an external site.
 
L

Lloyd Codrington

Ken

Thanks for the link. I saw the name and was unsure if I would get a screen
full of Co*k. But it looks like I'll find loads of code there.

All the best.
Lloyd
 
L

Lloyd Codrington

Jose,
Sorry mate but I have been getting an error message: 'unterminated string
constant.' I am just a beginner at all this website business so is there any
bit of code I may need to include that I don't know about. I replaced the <a
href="http://www.yomaster......... part of the code with relevent code but
still got the error.

Thanks mate
Lloyd

Jose Carlos said:
That's right, Lloyd!
Here I am a new script that you can prove:
Copy&Paste the next block:
<td>
<div align="center">
<table border="0" cellspacing="0" cellpadding="0" width="96">
<tr>
<td width="94"><script language="JavaScript1.2">
<!--

var sliderwidth=500
var sliderheight=150
var slidespeed=5

var leftrightslide=new Array()
var finalslide=''
leftrightslide[0]='<a href="http://www.yomaster.galeon.com"
target="_blank"><img src="images/banner1.gif" border=1 alt="Clic aquí para
ver."></a>'
leftrightslide[1]='<a href="http://www.yomaster.galeon.com"
target="_blank"><img src="images/banner0.gif" border=1 alt="Clic aquí para
ver."></a>'
leftrightslide[2]='<a href="http://www.yomaster.galeon.com"
target="_blank"><img src="images/banner.gif" border=1 alt="Clic aquí para
ver."></a>'


var copyspeed=slidespeed
for (i=0;i<leftrightslide.length;i++)
finalslide=finalslide+leftrightslide+" "


if (document.all){
document.write('<marquee id="ieslider" scrollAmount=0
style="width:'+sliderwidth+'">'+finalslide+'</marquee>')
ieslider.onmouseover=new Function("ieslider.scrollAmount=0")
ieslider.onmouseout=new Function("if (document.readyState=='complete')
ieslider.scrollAmount=slidespeed")
}

function regenerate(){
window.location.reload()
}
function regenerate2(){
if (document.layers){
document.ns_slider01.visibility="show"
setTimeout("window.onresize=regenerate",450)
intializeleftrightslide()
}
if (document.all)
ieslider.scrollAmount=slidespeed
}

function intializeleftrightslide(){
document.ns_slider01.document.ns_slider02.document.write('<nobr>'+finalslide+'</nobr>')
document. ns_slider01.document.ns_slider02.document.close()
thelength=document.ns_slider01.document.ns_slider02.document.width
scrollslide()
}

function scrollslide(){
if (document.ns_slider01.document.ns_slider02.left>=thelength*(-1)){
document.ns_slider01.document.ns_slider02.left-=slidespeed
setTimeout("scrollslide()",100)
}
else{
document.ns_slider01.document.ns_slider02.left=sliderwidth
scrollslide()
}
}
window.onload=regenerate2

//-->
</script>
<ilayer width=&{sliderwidth}; height=&{sliderheight};
name="ns_slider01" visibility=hide>
<layer name="ns_slider02" onMouseover="slidespeed=0;"
onMouseout="slidespeed=copyspeed">
</layer>
</ilayer>
<p align="center" style="margin-top: 0; margin-bottom:
0"> </td>
</tr>
</table>
</div>
</td>

Well,As you see, its contains the structure <a href="..."><img ...>, which
you can change.
I hope I have helped you this time..

"Lloyd Codrington" escribió:
Hi Jose,

Thanks for your solution but the script seems to be one for loading images
i.e. jpg, gif, wmfs' etc. What I need however is one that is capable of
loading HTML code such as the example below:

<a href="http://www.awine.co.uk/awclick.php?mid=435&linkid=7881&id=666"
target="_blank">
<img src="http://www.awine.co.uk/show.php?mid=435&linkid=7881&aid=666"
border="0" vspace="3"></a><br>

I have quite a few bits of code like this and was hopeing to save them as
individual files outside of the actual page to speed up loading. So I was
hoping any solution would call the file and execute the code in the page
being displayed.

Thanks again for the script you posted I know that will come in handy but it
is not exactly what I needed for this function.

All the best.

ps - Your English was fine.


Jose Carlos said:
Hi, Lloyd!
You can use this Javascript code for you carousel:

var lista = new Array('1.jpg', '2.jpg', '3.jpg' , '4.jpg');
var contador = 0;
var tiempo = 0;
var tempor = null;
function cambio(sen)
{
contador+= sen;
if (contador ==lista.length)
contador = lista.length-1;
else
if (contador < 0) contador = 0;
document.images.centro.src = lista[contador]
window.status="Imagen número "+contador
}
function reset()
{
contador = 0;
fin = false;
document.images.centro.src = lista[0]
}
function automat(seg)
{
tiempo = parseInt(seg);
reset();
window.status="Pase automático";
if (isNaN(tiempo) || tiempo <= 0)
alert("Error en el tiempo")
else
tempor = setTimeout("pasar()", tiempo)
}
function parar()
{
clearTimeout(tempor);
}
function pasar()
{
cambio(1);
if (contador < lista.length-1)
tempor = setTimeout("pasar()", tiempo)
}

Remember, you must include labels <script> and </script> in the beginning
and in the end of the code. I have made it for four images, but you can put
whatever you want.
Sorry, my english isn't very good...


"Lloyd Codrington" escribió:

I am building a site and have a few banners I wish to display. Can anyone
help me code a delay that would then load the next banner? Each banner code
is in HTML and includes a link to an external site.
 
F

Fred

Thanks for the information.

I used this thread to disciover how to center the text in a marquee by
inserting your code: <div align="center">
--

/Fred/


Jose Carlos said:
That's right, Lloyd!
Here I am a new script that you can prove:
Copy&Paste the next block:
<td>
<div align="center">
<table border="0" cellspacing="0" cellpadding="0" width="96">
<tr>
<td width="94"><script language="JavaScript1.2">
<!--

var sliderwidth=500
var sliderheight=150
var slidespeed=5

var leftrightslide=new Array()
var finalslide=''
leftrightslide[0]='<a href="http://www.yomaster.galeon.com"
target="_blank"><img src="images/banner1.gif" border=1 alt="Clic aquí para
ver."></a>'
leftrightslide[1]='<a href="http://www.yomaster.galeon.com"
target="_blank"><img src="images/banner0.gif" border=1 alt="Clic aquí para
ver."></a>'
leftrightslide[2]='<a href="http://www.yomaster.galeon.com"
target="_blank"><img src="images/banner.gif" border=1 alt="Clic aquí para
ver."></a>'


var copyspeed=slidespeed
for (i=0;i<leftrightslide.length;i++)
finalslide=finalslide+leftrightslide+" "


if (document.all){
document.write('<marquee id="ieslider" scrollAmount=0
style="width:'+sliderwidth+'">'+finalslide+'</marquee>')
ieslider.onmouseover=new Function("ieslider.scrollAmount=0")
ieslider.onmouseout=new Function("if (document.readyState=='complete')
ieslider.scrollAmount=slidespeed")
}

function regenerate(){
window.location.reload()
}
function regenerate2(){
if (document.layers){
document.ns_slider01.visibility="show"
setTimeout("window.onresize=regenerate",450)
intializeleftrightslide()
}
if (document.all)
ieslider.scrollAmount=slidespeed
}

function intializeleftrightslide(){
document.ns_slider01.document.ns_slider02.document.write('<nobr>'+finalslide+'</nobr>')
document. ns_slider01.document.ns_slider02.document.close()
thelength=document.ns_slider01.document.ns_slider02.document.width
scrollslide()
}

function scrollslide(){
if (document.ns_slider01.document.ns_slider02.left>=thelength*(-1)){
document.ns_slider01.document.ns_slider02.left-=slidespeed
setTimeout("scrollslide()",100)
}
else{
document.ns_slider01.document.ns_slider02.left=sliderwidth
scrollslide()
}
}
window.onload=regenerate2

//-->
</script>
<ilayer width=&{sliderwidth}; height=&{sliderheight};
name="ns_slider01" visibility=hide>
<layer name="ns_slider02" onMouseover="slidespeed=0;"
onMouseout="slidespeed=copyspeed">
</layer>
</ilayer>
<p align="center" style="margin-top: 0; margin-bottom:
0"> </td>
</tr>
</table>
</div>
</td>

Well,As you see, its contains the structure <a href="..."><img ...>, which
you can change.
I hope I have helped you this time..

"Lloyd Codrington" escribió:
Hi Jose,

Thanks for your solution but the script seems to be one for loading images
i.e. jpg, gif, wmfs' etc. What I need however is one that is capable of
loading HTML code such as the example below:

<a href="http://www.awine.co.uk/awclick.php?mid=435&linkid=7881&id=666"
target="_blank">
<img src="http://www.awine.co.uk/show.php?mid=435&linkid=7881&aid=666"
border="0" vspace="3"></a><br>

I have quite a few bits of code like this and was hopeing to save them as
individual files outside of the actual page to speed up loading. So I was
hoping any solution would call the file and execute the code in the page
being displayed.

Thanks again for the script you posted I know that will come in handy but it
is not exactly what I needed for this function.

All the best.

ps - Your English was fine.


Jose Carlos said:
Hi, Lloyd!
You can use this Javascript code for you carousel:

var lista = new Array('1.jpg', '2.jpg', '3.jpg' , '4.jpg');
var contador = 0;
var tiempo = 0;
var tempor = null;
function cambio(sen)
{
contador+= sen;
if (contador ==lista.length)
contador = lista.length-1;
else
if (contador < 0) contador = 0;
document.images.centro.src = lista[contador]
window.status="Imagen número "+contador
}
function reset()
{
contador = 0;
fin = false;
document.images.centro.src = lista[0]
}
function automat(seg)
{
tiempo = parseInt(seg);
reset();
window.status="Pase automático";
if (isNaN(tiempo) || tiempo <= 0)
alert("Error en el tiempo")
else
tempor = setTimeout("pasar()", tiempo)
}
function parar()
{
clearTimeout(tempor);
}
function pasar()
{
cambio(1);
if (contador < lista.length-1)
tempor = setTimeout("pasar()", tiempo)
}

Remember, you must include labels <script> and </script> in the beginning
and in the end of the code. I have made it for four images, but you can put
whatever you want.
Sorry, my english isn't very good...


"Lloyd Codrington" escribió:

I am building a site and have a few banners I wish to display. Can anyone
help me code a delay that would then load the next banner? Each banner code
is in HTML and includes a link to an external site.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top