PDA

View Full Version : How to Insert the Degree Symbol


areed248
01-11-2006, 10:54 AM
I need to insert the degree symbol into my output. I know that in html, the symbol is ° or °. How do I include the html in javascript? Everything that I try returns an error.

Gurok
01-11-2006, 11:08 AM
In Firefox, you can insert a degree symbol as follows:


document.body.appendChild(document.createTextNode("\u00B0"));


"00B0" is the hexadecimal value of the degree symbol's index in the Unicode character set.

You can append it to output like so:


myOutput += "\u00B0";


You may need to modify it for other browsers, but it's a start. Hope this helps.

Kor
01-11-2006, 11:58 AM
here's an online unicode convertor:
http://www.hot-tips.co.uk/useful/unicode_converter.HTML

When trying to insert a special character in a javascript string, you must always use its unicode escape value

\uXXXX , where XXXX is the hexa digits value of the ASCII