Connecting Tech Pros Worldwide Forums | Help | Site Map

How to have a variable text on a webpage

Stefan Mueller
Guest
 
Posts: n/a
#1: Nov 24 '05
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").firstChil d.replaceData(0,
document.getElementById("MyPlaceholder").firstChil d.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



Evertjan.
Guest
 
Posts: n/a
#2: Nov 24 '05

re: How to have a variable text on a webpage


Stefan Mueller wrote on 24 nov 2005 in comp.lang.javascript:
[color=blue]
> 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").firstChil d.replaceData(0,
> document.getElementById("MyPlaceholder").firstChil d.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?[/color]

just put it there:

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

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

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


--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Stefan Mueller
Guest
 
Posts: n/a
#3: Nov 24 '05

re: How to have a variable text on a webpage


> just put it there:[color=blue]
>
> <div id = 'MyPlaceholder'>Old Text.</div>
>
> ...............
>
> document.getElementById('MyPlaceholder').innerHTML =
> 'My new text.';[/color]

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

Many thanks
Stefan


Closed Thread