Having a pound sign (#) in the textarea
cause some problems when downloading the whole text in it.
I have this code:
<form>
some input: <input type="text" id ="input"/>
<input type="button" value="Submit" onclick="f1();"/>
</form>
<div class="preview">
This is some input:<br/>
<textarea id="generatedCode"></textarea><br/>
<input type="button" value="Download" onclick="f2();"/>
</div>
<script>
function f1(){
var input = document.getElementById('input');
var generatedCode = document.getElementById('generatedCode');
generatedCode.innerHTML = input.value
}
function f2(){
const content = document.getElementById("generatedCode").value;
var save = document.createElement("a");
save.setAttribute("href", "data:text/plain;charset=utf-8," + encodeURI(content));
save.setAttribute("download", content.slice(0, 17) + ".txt");
document.body.appendChild(save);
save.click();
document.body.removeChild(save);
}
</script>
Whenever you input some text with and a "#" then another text, then download it. The downloaded got no "#" and the remaining text. This cause me a problem. I'd like to download the whole text in textarea
including the "#" and the remaining text.