Ver Mensaje Individual
  #5 (permalink)  
Antiguo 12/09/2002, 17:23
Avatar de Beakdan
Beakdan
 
Fecha de Ingreso: diciembre-2001
Ubicación: Monterrey, Nuevo León
Mensajes: 433
Antigüedad: 23 años, 1 mes
Puntos: 7
Re: cambio de imagen

Código:
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<SCRIPT language="JavaScript">
<!--
menuCerrado = new Image();
menuCerrado.src = "obook.gif";
menuAbierto = new Image();
menuAbierto.src = "cbook.gif";

function cambiaImagen(){
	if(this.imagen.src==menuCerrado.src){
		this.imagen.src=menuAbierto.src;
	}else{
		this.imagen.src=menuCerrado.src;
	}
	//alert(img.id);
}

function AsignaValoresObj(){
	htmStr='<img src="' + menuAbierto.src + '" id="img' + this.id + '"> Soy el ' + this.id;
	this.innerHTML = htmStr;
	this.posTop = Math.round(Math.random() * document.body.clientHeight);
	this.posLeft = Math.round(Math.random() * document.body.clientWidth);
	this.ancho = 100;
	objImg = eval("img" + this.id);
	this.imagen = objImg;
	this.cambio = cambiaImagen;
	with(this.style){
		backgroundColor = "#ffaa55";
		pixelTop = this.posTop;
		pixelLeft = this.posLeft;
		cursor = "hand";
		font = "9pt Arial";
	}
}

function creaObj(numObj){
	for (i=1; i<=numObj; i++){
		nombreObj = 'Objeto' + i;
		definirDiv = '<div id="' + nombreObj + '" STYLE="position:absolute" onclick="this.cambio()"></DIV>';
		document.body.insertAdjacentHTML("BeforeEnd",definirDiv);
		objActual = eval(nombreObj);
		objActual.AsignaValores = AsignaValoresObj;
		objActual.AsignaValores();
	}
}

//-->
</script>
</HEAD>
<BODY BGCOLOR="#FFFFFF" onload="creaObj(15);">

</BODY>
</HTML>
Espero que te ayude. Saludos.