
23/09/2009, 05:53
|
 | Me alejo de Omelas | | Fecha de Ingreso: mayo-2004 Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 20 años, 9 meses Puntos: 834 | |
Respuesta: Problema al leer desde javascript un fichero .txt en local Probá así:
Código:
<!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></title>
<script>
function tratarCadena(cadena){
alert(cadena);
}
onload=function(){
var url2 = 'test.txt';
var ifr = document.createElement("iframe");
ifr.src = url2;
ifr.style.position='absolute';
ifr.style.left='-1500px';
ifr.onload = function() {
var doc=this.contentWindow.document || this.contentDocument;
window.contenidoIframe=doc.body.innerHTML;
}
ifr.onreadystatechange=function() {
var doc=this.contentWindow.document || this.contentDocument;
window.contenidoIframe=doc.body.innerHTML;
}
document.getElementsByTagName("body")[0].appendChild(ifr);
}
var intervalo=setInterval(function(){
if(window.contenidoIframe){
tratarCadena(window.contenidoIframe);
clearInterval(intervalo);
intervalo=null;
}
},10);
</script>
</head>
<body>
</body>
</html>
|