Foros del Web » Programando para Internet » Javascript »

Como hacer para que acepte también imagenes gif?

Estas en el tema de Como hacer para que acepte también imagenes gif? en el foro de Javascript en Foros del Web. Hola a todos... Alguien me puede ayudar, para que este script rotador de banner .swf, acepte tambien gif? Gracias y un saludo!!! Código HTML: <SCRIPT ...
  #1 (permalink)  
Antiguo 01/11/2006, 21:17
 
Fecha de Ingreso: octubre-2004
Mensajes: 768
Antigüedad: 19 años, 6 meses
Puntos: 3
Como hacer para que acepte también imagenes gif?

Hola a todos...
Alguien me puede ayudar, para que este script rotador de banner .swf, acepte tambien gif?
Gracias y un saludo!!!

Código HTML:
<SCRIPT LANGUAGE="JavaScript">

// Comienzo
var banners = 3;
var ahora = new Date()
var segundos = ahora.getSeconds()
var ad = segundos % banners;
ad +=1;
if (ad==1) {
flash="images/encomun/240x74_anuncio.swf"
width="295";
height="90";
}
if (ad==2) {
flash="images/bantrigoban.swf"
width="289";
height="100";
}
if (ad==3) {
flash="images/encomun/foros_295x80.swf"
width="295";
height="80";
}
document.write('<center>');
document.write('<OBJECT CLASSID=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=' + width + ' height=' + height + ' CODEBASE=\"http://active.macromedia.com/flash4/cabs/swflash.cab#version=4,0,0,0\">');
document.write('<PARAM NAME=\"MOVIE\" VALUE=\"' + flash + '\">');
document.write('<PARAM NAME=\"PLAY\" VALUE=\"true\">');
document.write('<PARAM NAME=\"LOOP\" VALUE=\"true\">');
document.write('<PARAM NAME=\"QUALITY\" VALUE=\"high\">');
document.write('<EMBED SRC=' + flash + ' width=' + width + ' height=' + height + ' PLAY=\"true\" LOOP=\"true\" QUALITY=\"high\" PLUGINSPAGE=\"http://www.macromedia.com/shockwave/download/index.cgi? P1_Prod_Version=ShockwaveFlash\">');
document.write('</EMBED>');
document.write('</OBJECT>');
document.write('</center>');
// Fin

</SCRIPT> 
  #2 (permalink)  
Antiguo 02/11/2006, 03:50
Avatar de djreficul  
Fecha de Ingreso: julio-2006
Ubicación: Cork
Mensajes: 672
Antigüedad: 17 años, 9 meses
Puntos: 0
Podrías pillas la extensión del archivo y hacer:

Código HTML:
document.write('<center>');
if (extension=='swf') {
document.write('<OBJECT CLASSID=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=' + width + ' height=' + height + ' CODEBASE=\"http://active.macromedia.com/flash4/cabs/swflash.cab#version=4,0,0,0\">');
document.write('<PARAM NAME=\"MOVIE\" VALUE=\"' + flash + '\">');
document.write('<PARAM NAME=\"PLAY\" VALUE=\"true\">');
document.write('<PARAM NAME=\"LOOP\" VALUE=\"true\">');
document.write('<PARAM NAME=\"QUALITY\" VALUE=\"high\">');
document.write('<EMBED SRC=' + flash + ' width=' + width + ' height=' + height + ' PLAY=\"true\" LOOP=\"true\" QUALITY=\"high\" PLUGINSPAGE=\"http://www.macromedia.com/shockwave/download/index.cgi? P1_Prod_Version=ShockwaveFlash\">');
document.write('</EMBED>');
document.write('</OBJECT>');

} else {
document.write ('<img src="'+flash+'" width="'+width+'" height="'+height+'" border="0">');
}
document.write('</center>');
Saludos.
__________________
La muerte es un camino que todos debemos recorrer...
  #3 (permalink)  
Antiguo 02/11/2006, 13:12
 
Fecha de Ingreso: octubre-2004
Mensajes: 768
Antigüedad: 19 años, 6 meses
Puntos: 3
Gracias djreficul...

No anda... de esa forma me muestra la pagina en blanco
La verdad que no me doy cuenta como hacer para insertarle las otras imagenes...
Saludos.-
  #4 (permalink)  
Antiguo 03/11/2006, 11:24
Avatar de djreficul  
Fecha de Ingreso: julio-2006
Ubicación: Cork
Mensajes: 672
Antigüedad: 17 años, 9 meses
Puntos: 0
Javascript no provoca q la página salga en blanco... o bien genera errores lo cuales se pueden leer en la Consola Javascript o, en el caso de Internet Explorer, el icono de listo pasa a tener una admiración.

Así q comenta qué clase de error te dá y si la página contiene más cosas q deberían salir aparte del banner el hexo de q salga en blanco se deberá a... ¿un error en código de servidor (¿PHP?)?

Saludos.
__________________
La muerte es un camino que todos debemos recorrer...
  #5 (permalink)  
Antiguo 03/11/2006, 11:54
 
Fecha de Ingreso: octubre-2004
Mensajes: 768
Antigüedad: 19 años, 6 meses
Puntos: 3
Hola djreficul...

Gracias por la ayuda...
Mira, probandolo de esta forma y con el cambio que me has dicho... no me muestra nada y no me da ningún aviso, ni en Firefox ni en IE...
Sin el cambio me muestra los .swf

Código HTML:
<html>
<head>
    <title>Selección de Banners Aleatorios</title>
</head>

<body>
<SCRIPT LANGUAGE="JavaScript">

// Comienzo
var banners = 3;
var ahora = new Date()
var segundos = ahora.getSeconds()
var ad = segundos % banners;
ad +=1;
if (ad==1) {
flash="images/encomun/240x74_anuncio.swf"
width="295";
height="90";
}
if (ad==2) {
flash="images/bantrigoban.gif"
width="289";
height="100";
}
if (ad==3) {
flash="images/encomun/foros_295x80.swf"
width="295";
height="80";
}
document.write('<center>');
if (extension=='swf') {
document.write('<OBJECT CLASSID=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=' + width + ' height=' + height + ' CODEBASE=\"http://active.macromedia.com/flash4/cabs/swflash.cab#version=4,0,0,0\">');
document.write('<PARAM NAME=\"MOVIE\" VALUE=\"' + flash + '\">');
document.write('<PARAM NAME=\"PLAY\" VALUE=\"true\">');
document.write('<PARAM NAME=\"LOOP\" VALUE=\"true\">');
document.write('<PARAM NAME=\"QUALITY\" VALUE=\"high\">');
document.write('<EMBED SRC=' + flash + ' width=' + width + ' height=' + height + ' PLAY=\"true\" LOOP=\"true\" QUALITY=\"high\" PLUGINSPAGE=\"http://www.macromedia.com/shockwave/download/index.cgi? P1_Prod_Version=ShockwaveFlash\">');
document.write('</EMBED>');
document.write('</OBJECT>');

} else {
document.write ('<img src="'+flash+'" width="'+width+'" height="'+height+'" border="0">');
}
document.write('</center>');
// Fin

</SCRIPT>

</body>
</html> 
  #6 (permalink)  
Antiguo 03/11/2006, 11:58
Avatar de djreficul  
Fecha de Ingreso: julio-2006
Ubicación: Cork
Mensajes: 672
Antigüedad: 17 años, 9 meses
Puntos: 0
Es q te falta obtener la extension del archivo... yo solo te orienté...

Para obtener la extensión añade a la parte:

Código HTML:
if (ad==X) { //X para hacer referencia a q es para todos
flash="images/encomun/foros_295x80.swf"
width="295";
height="80";
temp=flash.split(".");
extension=temp[(temp.length-1)];
}
Espero q con esto se solvente el problema...

Saludos.

EDITO: He sido muy bruto... no es necesario añadirlo a todos. Solo despues de los if

Código HTML:
if (ad==1) {
flash="images/encomun/240x74_anuncio.swf"
width="295";
height="90";
}
if (ad==2) {
flash="images/bantrigoban.gif"
width="289";
height="100";
}
if (ad==3) {
flash="images/encomun/foros_295x80.swf"
width="295";
height="80";
}
temp=flash.split(".");
extension=temp[(temp.length-1)];
Saludos nuevamente.
__________________
La muerte es un camino que todos debemos recorrer...
  #7 (permalink)  
Antiguo 03/11/2006, 15:50
 
Fecha de Ingreso: octubre-2004
Mensajes: 768
Antigüedad: 19 años, 6 meses
Puntos: 3
Perfecto djreficul...!!!

Aquí el único bruto soy yo!!!
Gracias djreficul, realmente muchas gracias por la ayuda y tu tiempo... anda perfecto!!!
Ahora me pongo a investigar para poder agregarle los enlaces a los gif... pero el script está bueno y así de completo no lo he visto!!!
Nuevamente gracias!!!
Saludos.-
  #8 (permalink)  
Antiguo 03/11/2006, 18:32
 
Fecha de Ingreso: octubre-2004
Mensajes: 768
Antigüedad: 19 años, 6 meses
Puntos: 3
Listo... ya está

Listo... Rotador de banners al refrescar la página, que acepta .swf y .gif a los cuales se les puede poner enlace y texto!!!
Script de Fabian Muller y modificado por "djreficul" y una muy pequeña ayuda de "paulkees" para forosdelweb.
Este script no lo he visto y lo he buscado mucho... tal vez para muchos sea algo simple... pero para novatos como yo está muy bueno!!!

Código HTML:
<html>
<head>
    <title>Selección de Banners Aleatorios</title>
</head>

<body>
<SCRIPT LANGUAGE="JavaScript">
// Realizado por: Fabian Muller y modificado por "djreficul" y una muy pequeña ayudita de "paulkees" de ForosdelWeb.com
// WebExperto.com - Ayuda al webmaster en español

// Comienzo
var banners = 3;
var ahora = new Date()
var segundos = ahora.getSeconds()
var ad = segundos % banners;
ad +=1;
if (ad==1) {
flash="images/banners/240x74_anuncio.swf"
width="295";
height="90";
}
if (ad==2) {
flash="images/bantrigoban.gif"
width="289";
height="100";
url="http://www.rawk.com.ar";
txt="¡Conoce rawk.com.ar ahora!";
}
if (ad==3) {
flash="images/banners/foros_295x80.swf"
width="295";
height="80";
}

temp=flash.split(".");
extension=temp[(temp.length-1)];
document.write('<center>');
if (extension=='swf') {
document.write('<OBJECT CLASSID=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=' + width + ' height=' + height + ' CODEBASE=\"http://active.macromedia.com/flash4/cabs/swflash.cab#version=4,0,0,0\">');
document.write('<PARAM NAME=\"MOVIE\" VALUE=\"' + flash + '\">');
document.write('<PARAM NAME=\"PLAY\" VALUE=\"true\">');
document.write('<PARAM NAME=\"LOOP\" VALUE=\"true\">');
document.write('<PARAM NAME=\"QUALITY\" VALUE=\"high\">');
document.write('<EMBED SRC=' + flash + ' width=' + width + ' height=' + height + ' PLAY=\"true\" LOOP=\"true\" QUALITY=\"high\" PLUGINSPAGE=\"http://www.macromedia.com/shockwave/download/index.cgi? P1_Prod_Version=ShockwaveFlash\">');
document.write('</EMBED>');
document.write('</OBJECT>');
} else {
document.write('<a href=\"' + url + '\" target=\"_blank\">');
document.write ('<img src="'+flash+'" width="'+width+'" height="'+height+'" border="0">');
document.write('<center><small>' + txt + '</small></center></a>');
}
document.write('</center>');
// Fin

</SCRIPT>

</body>
</html> 
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 20:09.