Skip to content

Instantly share code, notes, and snippets.

@jgomo3
Created March 26, 2013 17:03
Show Gist options
  • Save jgomo3/5247143 to your computer and use it in GitHub Desktop.
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.
<!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