Tuesday, February 14, 2017

unescape



codea

<textarea id="atnbg20170214tu1006" style="height: 100px; width: 400px;"></textarea>

<div>
<a href="javascript:atnbg20170214tu1006()" style="color: greenyellow; font-size: 1.5em;">
replace the escaped HTML in the textarea with unescaped same HTML</a>
</div>

<script> 

function atnbg20170214tu1006() {

var textarea = document.getElementById("atnbg20170214tu1006") 

function unescape(escapedhtml) {
var halfunescaped = escapedhtml.replace(/&lt;/g, "<")
return halfunescaped.replace(/&gt;/g, ">")}

textarea.value = unescape(textarea.value)}

</script>

acode