473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

space on text node DOM2

Hi

var lbl=document.createElement('LABEL');
var txt=document.createTextNode('text');
lbl.appendChild(txt);

in above txt node i want a space infront of that

i tried below, but no use

var txt=document.createTextNode(' text');

any idea ???

Dec 3 '05 #1
3 4576


su***************@gmail.com wrote:

var txt=document.createTextNode(' text');


It is a text node so pass in a string with the characters you want and
not some HTML entity references.
var txt = document.createTextNode(String.fromCharCode(160) + 'text');

--

Martin Honnen
http://JavaScript.FAQTs.com/
Dec 3 '05 #2
su***************@gmail.com wrote:
var txt=document.createTextNode(' text');


Character entity references are defined by and in SGML-based markup
languages, not by and in programming languages like JS. Furthermore,
the above would not refer to a space character but to a "no-break space"
character in an SGML-based markup language. So you are looking either
for the space character

var txt = document.createTextNode(' text');

or the "no-break space" character, which would be either

var txt = document.createTextNode('*text');

(I am sending this in ISO-8859-1 encoding, so any ISO-8859-x encoding
should do) or

var txt = document.createTextNode('\xA0text');

or

var txt = document.createTextNode('\u00A0text');

Since escape sequences are more obvious, I suggest you use the latter.

Unicode escape sequences (`\u1234') are supported since JavaScript 1.3
(NN 4.06, 1998), probably since JScript 5.0 (IE/5.0 for Windows, March
1999), and all ECMAScript implementations (conforming to ECMA-262 of
June 1997).
PointedEars
Dec 3 '05 #3
thanks , i succeeded with u00A0

Dec 6 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Malcolm Dew-Jones | last post by:
I am looking at xslt 1.0 and trying to understand if empty text nodes are supposed to be stripped or not as the default behaviour. 3.4 starts by listing rules for when white space is not stripped...
17
by: Stanimir Stamenkov | last post by:
Is it possible to make two inline elements to appear adjacent stripping any white space appearing in between in the source? Example: <span class="adj">1</span> <span class="adj">2</span>...
5
by: Richard Lewis | last post by:
Hello Pythoners, I'm currently writing some Python to manipulate a semi-structured XML document. I'm using DOM (minidom) and I've got working code for transforming the document to HTML files and...
11
by: kenneth | last post by:
I just ran across this. #1 <DBColumn> 1 </DBColumn> #2 <DBColumn> </DBColumn> The data for #1 will be parsed and returned as " 1 ". I get a sequence of...
7
by: David Thielen | last post by:
Hi; This code is in J# so it looks a little weird but you could change it to C# in a couple of seconds. The problem here is a single space node returns as an empty node: public static void...
1
by: robert | last post by:
I have an xmldocument and need to set the preservewhitespace to true as after processing the document I want to write out the xml (using outerxml/innerxml) and have the identations preserved for...
4
by: kollatjorva | last post by:
Hi all I'm trying to get a value from an xml node 'Publisher' use the value as a name of an .css class. This works fine until I get a value from the Publisher node with white space in it. I've...
2
by: =?iso-8859-1?q?KLEIN_St=E9phane?= | last post by:
Hi, I've a xml svg file and I would like to update it with Python. First, I would like to fetch one dom node with getElementByID. I've one issue about this method. This is my example : ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.