programming.nbk: Home | Index | Next Page: Javascript: DOM | Previous Page: Javascript


 Javascript: change page text on the fly

For most browsers, you delimit the text to be replaced thusly:

    <div ID="testing">MSNBC.com</div>

For IE4, use the following to change the text:

    document.all.testing.innerHTML = "A very cool site!"

For IE5 and Netscape 6, use:

    document.getElementById("testing").innerHTML = "A very cool site!"

For Netscape 4, you must embed the text thusly:

    <ilayer name="testing"><layer name="testing2">MSNBC.com</layer></ilayer>

Then change it using:

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

programming.nbk: Home | Index | Next Page: Javascript: DOM | Previous Page: Javascript


Notebook exported on Monday, 7 July 2008, 18:56:06 PM Eastern Daylight Time