Created
August 24, 2017 19:47
-
-
Save benjaminaaron/804de6a58dcfcf722427a7b4f7249df6 to your computer and use it in GitHub Desktop.
download the content of a DOM element as text - run in browser console
This file contains 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
function saveAsTextFile(element, filename) { // via stackoverflow.com/a/32858416 | |
var textFileAsBlob = new Blob([element.innerHTML], {type:'text/plain'}); | |
var link = document.createElement("a"); | |
link.download = filename; | |
link.href = window.URL.createObjectURL(textFileAsBlob); // works only in Chrome without attaching it to the DOM | |
link.click(); | |
} | |
saveAsTextFile(document.getElementById("content"), "content.xml"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment