Ver Mensaje Individual
  #6 (permalink)  
Antiguo 17/12/2016, 15:02
mpozo
 
Fecha de Ingreso: noviembre-2015
Mensajes: 231
Antigüedad: 8 años, 6 meses
Puntos: 86
Respuesta: Leer un fichero dado con javaScript

El problema es que la data no es del tipo blob, sino string. Se me ha ocurrido que se puede incluir el archivo *txt. El texto ha de estar contenido en una variable
archivo.txt
Código txt:
Ver original
  1. variable = 'Este es el texto que será mostrado<br>una vez que haya sido leído';
Código Javascript:
Ver original
  1. <!DOCTYPE html>
  2. <html dir="ltr" lang="es-es">
  3.     <head>
  4.         <title></title>
  5.         <meta charset="utf-8">
  6.         <meta name="viewport" content="user-scalable=yes, width=device-width, initial-scale=1">
  7.         <style>
  8.  
  9.         </style>
  10.         <script src="archivo.txt"></script>
  11.         <script>
  12.             window.addEventListener('load', function() {
  13.  
  14.                 document.getElementById('mostrar').innerHTML = variable;
  15.  
  16.             }, false);
  17.         </script>
  18.     </head>
  19.     <body>
  20.         <div id="mostrar"></div>
  21.     </body>
  22. </html>