faqts : Computers : Programming : Languages : JavaScript : DHTML : DOM

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

54 of 58 people (93%) answered Yes
Recently 10 of 10 people (100%) answered Yes

Entry

How can I insert a character entity like &nbsp into a document from Javascript ?

Nov 17th, 2000 19:57
Ryan Christianson, Kevin Esler, http://www.ecma.ch/ecma1/STAND/ECMA-262.HTM


If you want to insert a non-breaking space you can insert it using the 
charactor code. Like this:

var nbsp = document.createTextNode( "\u00A0" );		
referenceToWhereYouWantIt.appendChild( nbsp );

The url above is to the complete ECMA Spec.