Ver Mensaje Individual
  #12 (permalink)  
Antiguo 06/02/2008, 12:11
Avatar de Panino5001
Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 20 años
Puntos: 834
Re: Refrescar porcentaje de barra de progreso

Aquí tenés el ejemplo completo:
Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<
title>test</title>
<
style>
#marco{
width:300px;
border:1px solid #000;position:relative;
}
#barra{
width:0background-color:#F00;
}
#estado{
position:absoluteleft:50%;
}
</
style>
<
script>
function 
aj(){
    if(
window.XMLHttpRequest){
        return new 
XMLHttpRequest();
    }
    else{
        try{
            return new 
ActiveXObject('Microsoft.XMLHTTP');
        }catch(
e){
            
alert('tu navegador no soporta ajax');
            return 
false;
        }
    }
}
var 
porciento;
function 
rpc(url){
   var 
rpc=aj();
    if(
rpc){
        
rpc.open('GET',url,true);
        
rpc.onreadystatechange=function(){
            if(
rpc.readyState==4){
                
porciento=rpc.responseText;
            }
        }
        
rpc.send(null);
    }
}

function 
progress(porcentaje){
document.getElementById('barra').style.width=document.getElementById('estado').innerHTML=porcentaje+'%';
}

window.onload=function(){

var 
pp=setInterval(function(){if(typeof porciento!='undefined')progress(porciento);if(porciento>99){clearInterval(pp);};rpc('procesando.php?'+Math.random());},50);
}
</script>
</head>

<body>
<div id="marco"><div id="estado"></div><div id="barra">&nbsp;</div></div>
</body>
</html> 
Ojo que había escrito ActiveX con la a en minúscula. Ya lo edité.

Última edición por Panino5001; 06/02/2008 a las 12:18