Created
March 26, 2013 17:03
-
-
Save jgomo3/5247143 to your computer and use it in GitHub Desktop.
Ejemplo de un archivo creado el cliente. Al visitar esta página automáticamente se presenta el diálogo de bajar el archivo.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<!-- | |
http://stackoverflow.com/questions/2897619/using-html5-javascript-to-generate-and-save-a-file | |
Ya que el API FileSave de HTML 5 no lo soportan todos los navegadores, use la | |
opción del Uri Content. | |
--> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Data Uri, ejemplo</title> | |
<meta name="description" content="Ejemplo de un archivo creado el cliente." /> | |
<script type="text/javascript"> | |
var content = "nombre;apellido;cedula;profesion\nJesus;Gomez;16004478;Computista\nAlfa;Ortiz;3777777;Ing. Agrónomo"; | |
var uriContent = "data:text/csv," + encodeURIComponent(content); | |
location.href=uriContent; | |
</script> | |
</head> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment