Dmitry <no****@nospam.com> wrote in message
news:cv***********@news.peterlink.ru...
Code sample:
<script>
alert("°")
document.write("°")
</script>
Question: How can I force alert() to produce the same
result as document.write() ?
unescape() does not work.
Thank you, Dmitry
You need to extract the numeric value from the html code, then convert it to
an integer whose value you convert to a single-character string.
alert( String.fromCharCode( parseInt( "°".replace( /\D/g, "" ) ) )
If you intend do this repeatedly, it's best to write a function:
function htmlToChar(charCode)
{
return String.fromCharCode( parseInt( charCode.replace( /\D/g, "" ) ) );
}
alert( htmlToChar("°") );
....unless someone knows another way that eludes me...
--
S.C.
http://makeashorterlink.com/?H3E82245A