timROGERS
21-03-2006, 08:16 PM
This is useful if you wanna make your page move quickly and easily :) It uses Javascript to replace an id (eg. <span id="this">Replaces this</span>). It works instantly and is very easy to use in different situations.
Getting it on your page
You need to put some code in your head tag to put it in your page - there are two options, easy and valid, the easy option is to put the following into the head tag:
<script type="text/javascript">
function idReplacer(id, what)
{
getter = document.getElementById(id);
getter.innerHTML = what;
}
</script>
If you want to follow standards paste the following into a blank file called replace.js:
function idReplacer(id, what)
{
getter = document.getElementById(id);
getter.innerHTML = what;
}
and then place the following in the head of where you want to use it:
<script type="text/javascript" src="replace.js" />
How to Use It
The beauty of using Javascript is that it is very easy to run. The easiest ways to start off with, are simply using a normal "A" tag like you use for links, but using "onClick" or "onMouseOver" instead of "href".
Create the span you want to replace, for example one called "here". To do that put the following - you could make it empty to start or you could just change the text:
<span id="here">Hello!</span>
and then to create a link to do the work do this:
<a href="#" onClick="idReplacer('here', 'REPLACING DONE');">REPLACE TEXT</a>
That link is activated when you click "REPLACE TEXT". What happens is the onClick function waits for a click, when it happens it activated the earlier Javascript function, idReplacer with the ID to replace as "here" (you made it earlier) and the text to replace it with as "REPLACING DONE".
Hopefully reading this has told you how to use it and how it works. If you want to make the thing happen when someone puts there mouse on the link, change onClick to onMouseOver.
Thanks,
Tim
Getting it on your page
You need to put some code in your head tag to put it in your page - there are two options, easy and valid, the easy option is to put the following into the head tag:
<script type="text/javascript">
function idReplacer(id, what)
{
getter = document.getElementById(id);
getter.innerHTML = what;
}
</script>
If you want to follow standards paste the following into a blank file called replace.js:
function idReplacer(id, what)
{
getter = document.getElementById(id);
getter.innerHTML = what;
}
and then place the following in the head of where you want to use it:
<script type="text/javascript" src="replace.js" />
How to Use It
The beauty of using Javascript is that it is very easy to run. The easiest ways to start off with, are simply using a normal "A" tag like you use for links, but using "onClick" or "onMouseOver" instead of "href".
Create the span you want to replace, for example one called "here". To do that put the following - you could make it empty to start or you could just change the text:
<span id="here">Hello!</span>
and then to create a link to do the work do this:
<a href="#" onClick="idReplacer('here', 'REPLACING DONE');">REPLACE TEXT</a>
That link is activated when you click "REPLACE TEXT". What happens is the onClick function waits for a click, when it happens it activated the earlier Javascript function, idReplacer with the ID to replace as "here" (you made it earlier) and the text to replace it with as "REPLACING DONE".
Hopefully reading this has told you how to use it and how it works. If you want to make the thing happen when someone puts there mouse on the link, change onClick to onMouseOver.
Thanks,
Tim