Page 1 of 1

How to change page contents dynamically using JavaScript

Posted: Sun Feb 28, 2010 10:47 pm
by Shane
Say we have following simple text:

Code: Select all

<div ID="testing">ROBOT.LK</div>
 
In Internet Explorer 4 or above, the script to change the above text is:

Code: Select all

document.all.testing.innerHTML = "A very nice site!" 
In Netscape 6 (works in IE6 as well), the idea to alter a text is very similar, except in the precise syntax:

Code: Select all

document.getElementById("testing").innerHTML = "A very nice site!" 
In Netscape 4:
First we need to set the required tags as follows.

Code: Select all

<ilayer name="testing"><layer name="testing2">ROBOT.LK</layer></ilayer> 
Then the code is as below:

Code: Select all

document.testing.document.test2.document.write("A very nice site!")
document.testing.document.test2.document.close()