Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

When using document.createTextNode( "some text here" ); and some text  
here contains an entity, should I use "£" or "£" in the text?

Denis McMahon,

Re: document.createTextNode()

2014-05-05 15:05, Denis McMahon wrote:

Quoted text here. Click to load it

The latter, but note that you need to be careful with the character  
encoding issue: the declared encoding of the file containing the code  
must match its actual encoding. Confusion will arise e.g. if the file is  
actually UTF-8 encoded but the browser interprets it as windows-1252 (a  
common default).

The notation £ has a meaning in HTML and some other markup  
languages only, not in JavaScript. It would work in JavaScript only when  
used in a string that is then passed as an argument to a function that  
parses its argument as HTML.

In a JavaScript string, you can use the escape notation \u00A3 for £,  
e.g. document.createTextNode("The total is \u00A342.00.") instead of
document.createTextNode("The total is £42.00."). This works  
independently of character encoding.


Re: document.createTextNode()

Denis McMahon wrote:

Quoted text here. Click to load it

Given these choices, you *must* use "£" (and declare the proper character  
encoding), otherwise you generate the equivalent of “£”.  HTML  
character entity references are only resolved with the proprietary  
“innerHTML” property.  You could have tried.

See a recent thread in comp.lang.javascript – where such (DOM/HTML5 API)  
questions belong – on using Unicode characters beyond U+007F in ECMAScript-
based programming languages.

When all you know is jQuery, every problem looks $(olvable).

Re: document.createTextNode()

In comp.infosystems.www.authoring.html message <lk7upg$l73$1@dont->, Mon, 5 May 2014 12:05:04, Denis McMahon

Quoted text here. Click to load it

That depends on your editing tools.  If you have any that use only 7-bit
characters, then you may not want to use the "£" character.

If you are running a Museum of Ancient Browsers, then you cannot use
&pound; but &#163; may well work in HTML.  \xA3 and \u00A3 will work in

But you could always test it.  If either representation does not work in
what you are writing, them don't use it.  If either works in one
ordinary browsers it is likely to work in all of them.

 (c) John Stockton, nr London UK.  ?  DOS 3.3, 6.20; WinXP.
  Web  < - FAQqish topics, acronyms and links.
   PAS EXE TXT ZIP via  <
   My DOS  < - also batprogs.htm.

Site Timeline