Tuesday, February 14, 2017

unescape test



codea

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

<div><a href="javascript:atnbg20170214tu1038()" style="color: greenyellow; font-size: 1.5em;">
replace the escaped HTML in the textarea with unescaped same HTML, then copy it from there into the display div</a></div>

<div id="atnbg20170214tu1038displayresult"></div>

<script> 

function atnbg20170214tu1038() {

var textarea = document.getElementById("atnbg20170214tu1038") 

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

textarea.value = unescape(textarea.value)

document.getElementById("atnbg20170214tu1038displayresult").innerHTML = textarea.value}

</script>
acode