How to have a variable text on a webpage

S

Stefan Mueller

Today I display a placeholder '.' on my webpage with
<h3 id = "MyPlaceholder">.</h3>

Later in my JavaScript I change the placeholder '.' to something else (e.g.
'My new text')
document.getElementById("MyPlaceholder").firstChild.replaceData(0,
document.getElementById("MyPlaceholder").firstChild.nodeValue.length, "My
new text");

In general this works great. But the command replaceData() does not exist in
IE 5.5.
Is there any other possibility to do what I'd like to do?

Stefan
 
E

Evertjan.

Stefan Mueller wrote on 24 nov 2005 in comp.lang.javascript:
Today I display a placeholder '.' on my webpage with
<h3 id = "MyPlaceholder">.</h3>

Later in my JavaScript I change the placeholder '.' to something else
(e.g. 'My new text')
document.getElementById("MyPlaceholder").firstChild.replaceData(0,
document.getElementById("MyPlaceholder").firstChild.nodeValue.length,
"My new text");

In general this works great. But the command replaceData() does not
exist in IE 5.5.
Is there any other possibility to do what I'd like to do?

just put it there:

<div id = 'MyPlaceholder'>Old Text.</div>

................

document.getElementById('MyPlaceholder').innerHTML =
'My new text.';
 
S

Stefan Mueller

just put it there:
<div id = 'MyPlaceholder'>Old Text.</div>

...............

document.getElementById('MyPlaceholder').innerHTML =
'My new text.';

Great, that's works on every browser and it's even much less complicated
than my try.

Many thanks
Stefan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top