Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do I modify text displayed?
Message
From
27/11/2002 04:46:16
 
 
To
26/11/2002 15:42:11
Mike Sue-Ping
Cambridge, Ontario, Canada
General information
Forum:
Internet
Category:
DHTML
Miscellaneous
Thread ID:
00727284
Message ID:
00727449
Views:
10
>Hi All,
>
>I have a HTML page that goes something like this:
>
>
><html>
><body>
><p>This is the initial text to be displayed</p>
></body>
></html>
>
>
>Now I wanted to change the text displayed in the paragraph to something like:
>
>"This is the modified text"
>
>after it is displayed in the browser. What is the object hierarchy to get to the text "caption". I believe it should begin with document.body but where does it end?
>
>TIA
>
>Mike

This can be dependant on the browser used, but the latest versions tend to be converging on the same techniques. Whatever browser, there are several ways of doing this. For IE6, possibly the easiest is to give the paragraph a unique ID :
<p id="para1">This is the initial text to be displayed</p>
this can then be modified with
para1.innerHTML="This is the modified text"
or following the full hierarchy
document.body.all.para1.innerHTML="This is the modified text"
The following links may be of use :
http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/
This is the standard for the DOM, which IE6 follows to a large extent, other browsers follow it to some degree too.

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/dhtml_reference_entry.asp
This is the IE specific information

http://www.w3schools.com/dhtml/default.asp
A comprehensive tutorial on DHTML, with lots of modifiable examples eg
http://www.w3schools.com/dhtml/tryit.asp?filename=trydhtml_dom_innertext
Len Speed
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform