Last active
December 16, 2015 21:09
-
-
Save rjcorwin/5497275 to your computer and use it in GitHub Desktop.
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
| window.URL = window.URL || window.webkitURL | |
| var blob = new Blob(['body { color: red; }'], {type: 'text/css'}) | |
| var link = document.createElement('a') | |
| link.innerHTML = 'Click to download style.css.' | |
| link.href = window.URL.createObjectURL(blob) | |
| // Name the Blob so it doesn't result in a gibberish name | |
| link.download = 'style.css' | |
| // Append the download link to the body | |
| document.body.appendChild(link) | |
| // Optionally, if you want this to immediately download and don't care about the download link, run the click method | |
| // link.click() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment