Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-11-2006, 10:54 AM   PM User | #1
areed248
New Coder

 
Join Date: Dec 2005
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
areed248 is an unknown quantity at this point
How to Insert the Degree Symbol

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.
areed248 is offline   Reply With Quote
Old 01-11-2006, 11:08 AM   PM User | #2
Gurok
New to the CF scene

 
Join Date: Jan 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Gurok is an unknown quantity at this point
In Firefox, you can insert a degree symbol as follows:

Code:
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:

Code:
myOutput += "\u00B0";
You may need to modify it for other browsers, but it's a start. Hope this helps.
Gurok is offline   Reply With Quote
Old 01-11-2006, 11:58 AM   PM User | #3
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
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
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

Last edited by Kor; 01-11-2006 at 12:03 PM..
Kor is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:50 PM.


Advertisement
Log in to turn off these ads.