Go to: Aardvark download page.


This is the JavaScript equivalent to a get rich quick scheme! You get a lot of bang for your bucks!

With the technique described in this tutorial you can replace a chunk of HTML in a loaded page with another block of code. In other words...you can change text, replace text with an image, replace an image with an SWF, add a table to an empty cell, etc, etc... Sounds exiting - don't you think?!

First place <div id="myDiv">xxxx code xxxx</div> tags around the code you want to change, and to give the div an ID.

Then all you need is one line of code:

document.getElementById("myDiv").innerHTML="the new code"

Let's make this a function and we'll use a link to send the new text to that function. (We can of course store the new content in a variable.)

<script type="text/javascript"><!--
function changeText(newText){

...and here is the link:

<a href='javascript:changeText("Hello World!")'>The text link</a>

Below you find some sample text, click this link and see if the script works!

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.