Skip to content

Instantly share code, notes, and snippets.

Created September 12, 2017 23:49
Show Gist options
  • Save anonymous/1da9171bb64c80f85d4eef90c1e5562e to your computer and use it in GitHub Desktop.
Save anonymous/1da9171bb64c80f85d4eef90c1e5562e to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/roqabuwuta
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<textarea name="" id="" cols="30" rows="10">{"hello": "world"}</textarea>
<a download="hoge.json" onclick="doDownload(this)">download</a>
<script id="jsbin-javascript">
function doDownload(a) {
var blob = new Blob(
[ JSON.stringify(JSON.parse(a.previousElementSibling.value), null, 2) ],
{ type : 'application/json' }
);
a.href = window.URL.createObjectURL(blob);
}
</script>
<script id="jsbin-source-javascript" type="text/javascript">function doDownload(a) {
var blob = new Blob(
[ JSON.stringify(JSON.parse(a.previousElementSibling.value), null, 2) ],
{ type : 'application/json' }
);
a.href = window.URL.createObjectURL(blob);
}
</script></body>
</html>
function doDownload(a) {
var blob = new Blob(
[ JSON.stringify(JSON.parse(a.previousElementSibling.value), null, 2) ],
{ type : 'application/json' }
);
a.href = window.URL.createObjectURL(blob);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment