Ver Mensaje Individual
  #8 (permalink)  
Antiguo 14/01/2011, 09:24
Avatar de Tecktonikrazy
Tecktonikrazy
 
Fecha de Ingreso: enero-2010
Mensajes: 224
Antigüedad: 14 años, 4 meses
Puntos: 3
Respuesta: llamar a una parte de codigo que tengo en un .js

En lugar de usar:

window.onload = inicio;
window.onload = fecha;

Usa una sola vez:

window.onload = function(){inicio();fecha();}


<script type="text/javascript">
function hora(){
var fecha = new Date()
var hora = fecha.getHours()
var minuto = fecha.getMinutes()
var segundo = fecha.getSeconds()
if (hora < 10) {hora = "0" + hora}
if (minuto < 10) {minuto = "0" + minuto}
if (segundo < 10) {segundo = "0" + segundo}
var horita = hora + ":" + minuto + ":" + segundo
document.getElementById('hora').firstChild.nodeValue = horita
tiempo = setTimeout('hora()',1000)
}

function inicio(){
document.getElementById('reloj').innerHTML = '<span id="hora">000000</span>';
hora();
}

function fecha(){
fecha = new Date()
mes = fecha.getMonth()
diaMes = fecha.getDate()
diaSemana = fecha.getDay()
anio = fecha.getFullYear()
dias = new Array('Domingo','Lunes','Martes','Miercoles','Juev es','Viernes','Sábado')
meses = new Array('01','02','03','04','05','06','07','08','09' ,'10','11','12')
document.getElementById('contenedor').innerHTML='<span id="fecha">'+diaMes + "-" + meses[mes] + "-" + anio+'</span>';
}

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

window.onload = function(){inicio();fecha();}
</script>


<table width="150" border="1">
<tr>
<td id="reloj" height="25" align="center"></td>
</table>

<table width="150" border="1">
<tr>
<td id="contenedor" height="25" align="center">
</td>
</tr>
</table>
__________________
I LOVE HTML (How To Make Love)