Foros del Web » Programando para Internet » Javascript »

Ayuda! sencilla para vosotros seguro

Estas en el tema de Ayuda! sencilla para vosotros seguro en el foro de Javascript en Foros del Web. Hola, hay un script q me permite cambiar un texto cada ciertos segundos haciendo el efecto fade, pero solo funciona el fade si el fondo ...
  #1 (permalink)  
Antiguo 06/12/2004, 14:21
 
Fecha de Ingreso: marzo-2004
Mensajes: 43
Antigüedad: 20 años, 1 mes
Puntos: 0
Ayuda! sencilla para vosotros seguro

Hola, hay un script q me permite cambiar un texto cada ciertos segundos haciendo el efecto fade, pero solo funciona el fade si el fondo es blanco, si es negro no va. Alguien podria ayudarme a ver q es lo q hago mal? o si conoce otro similar q si permite.... GRACIAS!!

Este es el script:

//comienza
<body>
<script language="JavaScript1.2">
var delay=3000 //pausa (en milisegundos)
var fcontent=new Array()
begintag='<font face="Arial" size=2>' //tag que abre los mensajes
fcontent[0]="<strong><b>Ejemplo...</b><br><br>Crear un sitio web es relativamente fácil. Lo dificil es darle un buen contenido, diseño y enfoque.</strong>"
fcontent[1]="<strong>El tener en un mismo sitio, mas de 3 paginas de informacion, cansa al visitante y lo hace dejar el sitio.</strong>"
fcontent[2]="<strong>Una de las causas por las que el visitante regresa a un sitio frecuentemente es porque bla, bla, bla.</strong>"
closetag='</font>'

var fwidth=150 //ancho
var fheight=150 //alto

///No editar/////////////////
var ie4=document.all&&!document.getElementById
var ns4=document.layers
var DOM2=document.getElementById
var faderdelay=0
var index=0

if (DOM2)
faderdelay=2000

// Function to change content
function changecontent(){
if (index>=fcontent.length)
index=0
if (DOM2){
document.getElementById("fscroller").style.color=" rgb(250,250,250)"
document.getElementById("fscroller").innerHTML=beg intag+fcontent[index]+closetag
colorfade()
}
else if (ie4)
document.all.fscroller.innerHTML=begintag+fcontent[index]+closetag
else if (ns4){
document.fscrollerns.document.fscrollerns_sub.docu ment.write(begintag+fcontent[index]+closetag)
document.fscrollerns.document.fscrollerns_sub.docu ment.close()
}

index++
setTimeout("changecontent()",delay+faderdelay)
}

// colorfade() partially by Marcio Galli for Netscape Communications. ////////////

frame=20;
hex=255 // Initial color value.

function colorfade() {
// 20 frames fading process
if(frame>0) {
hex-=12; // increase color value
document.getElementById("fscroller").style.color=" CCCCCC"; // Set color value. Para q funcione fade color="rgb("+250+","+hex+","+hex+")
frame--;
setTimeout("colorfade()",100); // Velocidad fade
}
else{
document.getElementById("fscroller").style.color=" CCCCCC"; // Color final
frame=20;
hex=255
}
}

if (ie4||DOM2)
document.write('<div id="fscroller" align="left" style="width:'+333+';height:'+200+'; position:absolute; z-index:1; left:333px; top:300px; padding:2px"></div>')

window.onload=changecontent
</script>
</body>
// Termina
  #2 (permalink)  
Antiguo 07/12/2004, 01:13
Avatar de fgil2  
Fecha de Ingreso: enero-2003
Ubicación: zaragoza
Mensajes: 285
Antigüedad: 21 años, 3 meses
Puntos: 0
Hola adancer:

Después de algunas modificaciones me ha quedado algo asi, mira a ver si te vale.
-----------------------------------------------------------------------------

<html>
<head>
</head>
<body bgcolor="#000000">
<script language="JavaScript1.2">

var delay=3000
var fcontent=new Array()
begintag='<font face="Arial" size=2>' //tag que abre los mensajes
fcontent[0]="<b>Ejemplo...</b><br><br>Crear un sitio web es relativamente fácil. Lo dificil es darle un buen contenido, diseño y enfoque"
fcontent[1]="El tener en un mismo sitio, mas de 3 paginas de informacion, cansa al visitante y lo hace dejar el sitio."
fcontent[2]="Una de las causas por las que el visitante regresa a un sitio frecuentemente es porque bla, bla, bla."
closetag='</font>'
var fwidth=250 //ancho
var fheight=90 //alto
var ie4=document.all&&!document.getElementById
var ns4=document.layers
var DOM2=document.getElementById
var faderdelay=0
var index=0
if (DOM2)
faderdelay=3000
function changecontent(){
if (index>=fcontent.length)
index=0
if (DOM2){
document.getElementById("fscroller").style.color=" rgb(255,255,255)"
document.getElementById("fscroller").innerHTML=beg intag+fcontent[index]+closetag
colorfade()
}
else if (ie4)
document.all.fscroller.innerHTML=begintag+fcontent[index]+closetag
else if (ns4){
document.fscrollerns.document.fscrollerns_sub.docu ment.write(begintag+fcontent[index]+closetag)
document.fscrollerns.document.fscrollerns_sub.docu ment.close()
}
index++
setTimeout("changecontent()",delay+faderdelay)
}
// colorfade() partially by Marcio Galli for Netscape Communications. ////////////
frame=20;
hex=255,255,255 // Initial color value.
function colorfade() {
// 20 frames fading process
if(frame>0) {
hex-=10; // increase color value
document.getElementById("fscroller").style.color=" rgb("+hex+","+hex+","+hex+")"; // Set color value.
frame--;
setTimeout("colorfade()",100);
}
else{
document.getElementById("fscroller").style.color=" rgb(0,0,0)";
frame=20;
hex=255
}
}
if (ie4||DOM2)
document.write('<div id="fscroller" style="border:1px solid white;width:'+fwidth+';height:'+fheight+';padding: 2px"></div>')
window.onload=changecontent
</script>
<ilayer id="fscrollerns" width="&amp;{fwidth};" height="&amp;{fheight};">
<layer id="fscrollerns_sub" width="&amp;{fwidth};" height="&amp;{fheight};" left="0" top="0">
</layer>
</ilayer>

</body>
</html>
__________________
fer
  #3 (permalink)  
Antiguo 07/12/2004, 06:44
 
Fecha de Ingreso: marzo-2004
Mensajes: 43
Antigüedad: 20 años, 1 mes
Puntos: 0
Muchas gracias por tu ayuda fgil2, buena comunidad teneis aqui.

Pero veras, yo necesito q el texto pase del negro, al color #CCCCCC (q es gris casi blanco), y al parecer solo puede ser al reves...
  #4 (permalink)  
Antiguo 07/12/2004, 09:07
Avatar de JavierB
Colaborador
 
Fecha de Ingreso: febrero-2002
Ubicación: Madrid
Mensajes: 25.052
Antigüedad: 22 años, 2 meses
Puntos: 772
Hola adancer

Cambia esta parte del código de fgil2:

// colorfade() partially by Marcio Galli for Netscape Communications. ////////////
frame=20;
hex=0,0,0 // Initial color value.
function colorfade() {
// 20 frames fading process
if(frame>0) {
hex+=10; // increase color value
document.getElementById("fscroller").style.color=" rgb("+hex+","+hex+","+hex+")"; // Set color value.
frame--;
setTimeout("colorfade()",100);
}
else{
document.getElementById("fscroller").style.color=" rgb(192,192,192)";
frame=20;
hex=0

Espero que te funcione. Saludos,
  #5 (permalink)  
Antiguo 07/12/2004, 10:01
 
Fecha de Ingreso: marzo-2004
Mensajes: 43
Antigüedad: 20 años, 1 mes
Puntos: 0
UAU!! Lo habeis conseguido! Increible, muchas gracias a los dos!!

Ha quedado mu wapo, el efecto, se lo recomiendo a la gente q lo emplee, q ademas si al final en el DIV ID le añade codigo quedando asi...

document.write('<div id="fscroller" align="justify" style="width:'+290+';height:'+290+'; position:absolute; z-index:1; left:355px; top:300px; padding:2px"></div>')

...puede situar el efecto donde quiera. Los dos Layers se pueden borrar si molestan, yo lo hize y figaros como queda en la web q esoy haciendo (http://www.la-companyia.com/index2.htm).

Asi quedaria el codigo aplicando los fantasticos cambios de fgil2 y JavierB:

//
<html>
<head>
</head>
<body bgcolor="#000000">
<script language="JavaScript1.2">

var delay=3000
var fcontent=new Array()
begintag='<font face="Arial" size=2>' //tag que abre los mensajes
fcontent[0]="<b>Ejemplo...</b><br><br>Crear un sitio web es relativamente fácil. Lo dificil es darle un buen contenido, diseño y enfoque"
fcontent[1]="El tener en un mismo sitio, mas de 3 paginas de informacion, cansa al visitante y lo hace dejar el sitio."
fcontent[2]="Una de las causas por las que el visitante regresa a un sitio frecuentemente es porque bla, bla, bla."
closetag='</font>'
var fwidth=250 //ancho
var fheight=90 //alto
var ie4=document.all&&!document.getElementById
var ns4=document.layers
var DOM2=document.getElementById
var faderdelay=0
var index=0
if (DOM2)
faderdelay=3000
function changecontent(){
if (index>=fcontent.length)
index=0
if (DOM2){
document.getElementById("fscroller").style.color=" rgb(255,255,255)"
document.getElementById("fscroller").innerHTML=beg intag+fcontent[index]+closetag
colorfade()
}
else if (ie4)
document.all.fscroller.innerHTML=begintag+fcontent[index]+closetag
else if (ns4){
document.fscrollerns.document.fscrollerns_sub.docu ment.write(begintag+fcontent[index]+closetag)
document.fscrollerns.document.fscrollerns_sub.docu ment.close()
}
index++
setTimeout("changecontent()",delay+faderdelay)
}
// colorfade() partially by Marcio Galli for Netscape Communications. ////////////
frame=20;
hex=0,0,0 // Initial color value.
function colorfade() {
// 20 frames fading process
if(frame>0) {
hex+=10; // increase color value
document.getElementById("fscroller").style.color=" rgb("+hex+","+hex+","+hex+")"; // Set color value.
frame--;
setTimeout("colorfade()",100);
}
else{
document.getElementById("fscroller").style.color=" rgb(192,192,192)";
frame=20;
hex=0
}
}
if (ie4||DOM2)
document.write('<div id="fscroller" style="border:1px solid white;width:'+fwidth+';height:'+fheight+';padding: 2px"></div>')
window.onload=changecontent
</script>
<ilayer id="fscrollerns" width="&amp;{fwidth};" height="&amp;{fheight};">
<layer id="fscrollerns_sub" width="&amp;{fwidth};" height="&amp;{fheight};" left="0" top="0">
</layer>
</ilayer>

</body>
</html>

Última edición por adancer; 07/12/2004 a las 10:14
  #6 (permalink)  
Antiguo 07/12/2004, 11:41
Avatar de fgil2  
Fecha de Ingreso: enero-2003
Ubicación: zaragoza
Mensajes: 285
Antigüedad: 21 años, 3 meses
Puntos: 0
Hola adancer:

Me alegro de que te haya servido, he visto tu web y está quedando muy bonita.

Saludos JavierB, tiempo sin coincidir... me alegro de seguir contando con tu ayuda.
Un abrazo.
__________________
fer
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:14.