html - JavaScript save text to file with spaces -
javascript
function savetextasfile() { var texttowrite = document.getelementbyid('out').innerhtml; var textfileasblob = new blob([texttowrite], {type:'text/plain'}); var filenametosaveas = document.getelementbyid("maze").value; var downloadlink = document.createelement("a"); downloadlink.href = window.webkiturl.createobjecturl(textfileasblob); downloadlink.download = filenametosaveas; downloadlink.click(); }
i'm trying here save text <pre id="out"></pre>
.txt file, function doesn't save spaces , line-spaces <pre>
tag, can see 1 long line in new .txt file. i'm missing here?
<pre>
contains '\r\n'