Foros del Web » Programando para Internet » Javascript »

¿que falla en este script???

Estas en el tema de ¿que falla en este script??? en el foro de Javascript en Foros del Web. este script hace el efecto de caer copos de nieve, pero la imagen del copo no sale, eso si el texto se ve....... auda please!!! ...
  #1 (permalink)  
Antiguo 15/12/2002, 07:18
Avatar de pereztroff  
Fecha de Ingreso: junio-2002
Ubicación: En la Internet.
Mensajes: 4.068
Antigüedad: 21 años, 10 meses
Puntos: 5
¿que falla en este script???

este script hace el efecto de caer copos de nieve, pero la imagen del copo no sale, eso si el texto se ve....... auda please!!!

<script language="JavaScript">

var snowsrc="/imagenes/snow.gif"
var no = 10;

var ns4up = (document.layers) ? 1 : 0; // browser sniffer
var ie4up = (document.all) ? 1 : 0;
var ns6up = (document.getElementById&&!document.all) ? 1 : 0;

var dx, xp, yp; // coordinate and position variables
var am, stx, styNav; // amplitude and step variables
var i, doc_width = 800, doc_height = 600;

if (ns4up||ns6up) {
doc_width = self.innerWidth;
doc_height = self.innerHeight;
} else if (ie4up) {
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
}

saltar = new Array();
for (i = 0; i < no; ++ i) {
saltar[i]=true;
}
mensaje = new Array();
mensaje[0]="F E L I Z N A V I D A D";
mensaje[1]="1 AÑO MAS EN INTERNET CON VOSOTR@S";
mensaje[2]="¡¡FELICES FIESTAS!!";
mensaje[3]="FELIZ NAVIDAD OS DESEA PEREZTROFF";
mensaje[4]="";
mensaje[5]="F e l i z N a v i d a d";
mensaje[6]="FELIZ NAVIDAD";
mensaje[7]="";
mensaje[8]="F e l i z N a v i d a d";
mensaje[9]="";
dx = new Array();
xp = new Array();
yp = new Array();
am = new Array();
stx = new Array();
styNav = new Array();

for (i = 0; i < no; ++ i) {
dx[i] = 0; // set coordinate variables
xp[i] = Math.random()*(doc_width-50); // set position variables
yp[i] = Math.random()*doc_height;
am[i] = Math.random()*20; // set amplitude variables
stx[i] = 0.02 + Math.random()/10; // set step variables
styNav[i] = 0.7 + Math.random(); // set step variables
if (ns4up) { // set layers
if (i == 0) {
document.write("<layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"><img src='"+snowsrc+"' border=\"0\" alt=\""+mensaje[i]+"\" onmouseover=javascript:saltar["+i+"]=false; onmouseout=javascript:saltar["+i+"]=true;></layer>");
} else {
document.write("<layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"><img src='"+snowsrc+"' border=\"0\" alt=\""+mensaje[i]+"\" onmouseover=javascript:saltar["+i+"]=false; onmouseout=javascript:saltar["+i+"]=true;></layer>");
}
} else if (ie4up||ns6up) {
if (i == 0) {
document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><img src='"+snowsrc+"' border=\"0\" alt=\""+mensaje[i]+"\" onmouseover=javascript:saltar["+i+"]=false; onmouseout=javascript:saltar["+i+"]=true;></div>");
} else {
document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><img src='"+snowsrc+"' border=\"0\" alt=\""+mensaje[i]+"\" onmouseover=javascript:saltar["+i+"]=false; onmouseout=javascript:saltar["+i+"]=true;></div>");
}
}
}

function snowNS() { // Netscape main animation function
for (i = 0; i < no; ++ i) { // iterate for every dot
if (saltar[i])
{
yp[i] += styNav[i];
if (yp[i] > doc_height-50) {
xp[i] = Math.random()*(doc_width-am[i]-30);
yp[i] = 0;
stx[i] = 0.02 + Math.random()/10;
styNav[i] = 0.7 + Math.random();
doc_width = self.innerWidth;
doc_height = self.innerHeight;
}
dx[i] += stx[i];
document.layers["dot"+i].top = yp[i];
document.layers["dot"+i].left = xp[i] + am[i]*Math.sin(dx[i]);
}
}
setTimeout("snowNS()", 75);
}

function snowIE_NS6() { // IE and NS6 main animation function
for (i = 0; i < no; ++ i) { // iterate for every dot
if (saltar[i])
{
yp[i] += styNav[i];
if (yp[i] > doc_height-50) {
xp[i] = Math.random()*(doc_width-am[i]-30);
yp[i] = 0;
stx[i] = 0.02 + Math.random()/10;
styNav[i] = 0.7 + Math.random();
doc_width = ns6up?window.innerWidth : document.body.clientWidth;
doc_height = ns6up?window.innerHeight : document.body.clientHeight;
}
dx[i] += stx[i];
if (ie4up){
document.all["dot"+i].style.pixelTop = yp[i];
document.all["dot"+i].style.pixelLeft = xp[i] + am[i]*Math.sin(dx[i]);
}
else if (ns6up){
document.getElementById("dot"+i).style.top=yp[i];
document.getElementById("dot"+i).style.left=xp[i] + am[i]*Math.sin(dx[i]);
}
}
}
setTimeout("snowIE_NS6()", 75);

}

if (ns4up) {
snowNS();
} else if (ie4up||ns6up) {
snowIE_NS6();
}
</script>
  #2 (permalink)  
Antiguo 15/12/2002, 07:23
Avatar de pereztroff  
Fecha de Ingreso: junio-2002
Ubicación: En la Internet.
Mensajes: 4.068
Antigüedad: 21 años, 10 meses
Puntos: 5
se me olvido comentar que probe el codigo en la siguiente web
www.pereztroff.com.ar

y veran que los copos de nieven no se ven, porque?????
  #3 (permalink)  
Antiguo 15/12/2002, 11:15
 
Fecha de Ingreso: diciembre-2001
Ubicación: Madrid
Mensajes: 889
Antigüedad: 22 años, 4 meses
Puntos: 4
Es simple, debes subir la imagen del copo a tu sitio, y si ya está subida, decirle al script en dónde se encuentra dicha imagen. Vi así por encima tu script y la única imagen que vi está en la primera línea del scrip:
var snowsrc="/imagenes/snow.gif"
Pon allí la ubicación correcta de tu imagen y problemilla solucionado :D

PD: Espero que no haya más

Última edición por chivi; 15/12/2002 a las 11:19
  #4 (permalink)  
Antiguo 15/12/2002, 13:15
Avatar de pereztroff  
Fecha de Ingreso: junio-2002
Ubicación: En la Internet.
Mensajes: 4.068
Antigüedad: 21 años, 10 meses
Puntos: 5
el caso es que la imagen esta subida a dicho directorio y el path indicado tambien, no entiendo porque no funciona.....


podra ser que cualquier otro script que tengo en el mismo archivo htm le influya????
  #5 (permalink)  
Antiguo 15/12/2002, 13:28
 
Fecha de Ingreso: diciembre-2001
Ubicación: Madrid
Mensajes: 889
Antigüedad: 22 años, 4 meses
Puntos: 4
Bien, tu error se basa en lo siguiente.
La página de la que hablamos es:
http://personal.telefonica.terra.es/...l/superior.htm ok? y la imagen, dónde vos la subió (la encontré de chiripa ) es: http://personal.telefonica.terra.es/...troff/snow.gif

¿Que es lo que ocurre? Que has subido la imagen directamente al raíz, en ves de a la carpeta en la cual corresponde la llamada en tu script. (Solo hay que mirar las direcciones y las carpetas de la misma).

¿Solución? Pues utiliza "../" (sin las comillas) para subir tantos directorios como necesites para llegar a tu imagen o más bien, mueve la imagen de snow.gif a la carpeta dónde se encuentra la página "superior.htm". (es lo que te recomiendo hacer).


Saludos!
  #6 (permalink)  
Antiguo 15/12/2002, 13:44
Avatar de pereztroff  
Fecha de Ingreso: junio-2002
Ubicación: En la Internet.
Mensajes: 4.068
Antigüedad: 21 años, 10 meses
Puntos: 5
he creado de prueba esta pagina: http://personal.telefonica.terra.es/...html/nieve.htm

con este codigo:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#000000" text="#FFFFFF">
<script language="JavaScript">

var snowsrc="/nuevodiseno/html/snow.gif"
var no = 10;

var ns4up = (document.layers) ? 1 : 0; // browser sniffer
var ie4up = (document.all) ? 1 : 0;
var ns6up = (document.getElementById&&!document.all) ? 1 : 0;

var dx, xp, yp; // coordinate and position variables
var am, stx, styNav; // amplitude and step variables
var i, doc_width = 800, doc_height = 600;

if (ns4up||ns6up) {
doc_width = self.innerWidth;
doc_height = self.innerHeight;
} else if (ie4up) {
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
}

saltar = new Array();
for (i = 0; i < no; ++ i) {
saltar[i]=true;
}
mensaje = new Array();
mensaje[0]="F E L I Z N A V I D A D";
mensaje[1]="1 AÑO MAS EN INTERNET CON VOSOTR@S";
mensaje[2]="¡¡FELICES FIESTAS!!";
mensaje[3]="FELIZ NAVIDAD OS DESEA PEREZTROFF";
mensaje[4]="";
mensaje[5]="F e l i z N a v i d a d";
mensaje[6]="FELIZ NAVIDAD";
mensaje[7]="";
mensaje[8]="F e l i z N a v i d a d";
mensaje[9]="";
dx = new Array();
xp = new Array();
yp = new Array();
am = new Array();
stx = new Array();
styNav = new Array();

for (i = 0; i < no; ++ i) {
dx[i] = 0; // set coordinate variables
xp[i] = Math.random()*(doc_width-50); // set position variables
yp[i] = Math.random()*doc_height;
am[i] = Math.random()*20; // set amplitude variables
stx[i] = 0.02 + Math.random()/10; // set step variables
styNav[i] = 0.7 + Math.random(); // set step variables
if (ns4up) { // set layers
if (i == 0) {
document.write("<layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"><img src='"+snowsrc+"' border=\"0\" alt=\""+mensaje[i]+"\" onmouseover=javascript:saltar["+i+"]=false; onmouseout=javascript:saltar["+i+"]=true;></layer>");
} else {
document.write("<layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"><img src='"+snowsrc+"' border=\"0\" alt=\""+mensaje[i]+"\" onmouseover=javascript:saltar["+i+"]=false; onmouseout=javascript:saltar["+i+"]=true;></layer>");
}
} else if (ie4up||ns6up) {
if (i == 0) {
document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><img src='"+snowsrc+"' border=\"0\" alt=\""+mensaje[i]+"\" onmouseover=javascript:saltar["+i+"]=false; onmouseout=javascript:saltar["+i+"]=true;></div>");
} else {
document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><img src='"+snowsrc+"' border=\"0\" alt=\""+mensaje[i]+"\" onmouseover=javascript:saltar["+i+"]=false; onmouseout=javascript:saltar["+i+"]=true;></div>");
}
}
}

function snowNS() { // Netscape main animation function
for (i = 0; i < no; ++ i) { // iterate for every dot
if (saltar[i])
{
yp[i] += styNav[i];
if (yp[i] > doc_height-50) {
xp[i] = Math.random()*(doc_width-am[i]-30);
yp[i] = 0;
stx[i] = 0.02 + Math.random()/10;
styNav[i] = 0.7 + Math.random();
doc_width = self.innerWidth;
doc_height = self.innerHeight;
}
dx[i] += stx[i];
document.layers["dot"+i].top = yp[i];
document.layers["dot"+i].left = xp[i] + am[i]*Math.sin(dx[i]);
}
}
setTimeout("snowNS()", 75);
}

function snowIE_NS6() { // IE and NS6 main animation function
for (i = 0; i < no; ++ i) { // iterate for every dot
if (saltar[i])
{
yp[i] += styNav[i];
if (yp[i] > doc_height-50) {
xp[i] = Math.random()*(doc_width-am[i]-30);
yp[i] = 0;
stx[i] = 0.02 + Math.random()/10;
styNav[i] = 0.7 + Math.random();
doc_width = ns6up?window.innerWidth : document.body.clientWidth;
doc_height = ns6up?window.innerHeight : document.body.clientHeight;
}
dx[i] += stx[i];
if (ie4up){
document.all["dot"+i].style.pixelTop = yp[i];
document.all["dot"+i].style.pixelLeft = xp[i] + am[i]*Math.sin(dx[i]);
}
else if (ns6up){
document.getElementById("dot"+i).style.top=yp[i];
document.getElementById("dot"+i).style.left=xp[i] + am[i]*Math.sin(dx[i]);
}
}
}
setTimeout("snowIE_NS6()", 75);

}

if (ns4up) {
snowNS();
} else if (ie4up||ns6up) {
snowIE_NS6();
}
</script>

</body>
</html>

puse el archivo htm y el gif dentro de la misma carpeta y respetando el path de ambos
  #7 (permalink)  
Antiguo 15/12/2002, 13:52
 
Fecha de Ingreso: diciembre-2001
Ubicación: Madrid
Mensajes: 889
Antigüedad: 22 años, 4 meses
Puntos: 4
¿quieres que llore? jejejeje

A ver.. para TODO script que hagas en un futuro, si tanto el SCRIPT como su IMAGEN o lo que fuere, están en el MISMO DIRECTORIO, NO necesitas darle un PATH. Dales simplemente el NOMBRE de la IMAGEN. ¿Ahora mejor? jejeje

¿Tu error?
var snowsrc="/nuevodiseno/html/snow.gif"
¿Correción?
var snowsrc="snow.gif"

(Te lo publico ahora mismito en mi web)
www.programadorweb.com/nieve.htm


Saludos!
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 01:03.