Example (IE5 or NS6 required to view)
If you're a JavaScript programmer, the chances are, you've heard of something called the DOM. However, just what exactly is it? How does you program use it?
As both IE and NS move toward conforming to the standards in terms of scripting syntax (especially in the area of DHTML), the pressure to learn and master the DOM increases. In fact, by all accounts it now seems, DHTML in NS 6 will be based entirely on the new DOM, with no support for legacy syntax.
Below we set out 1 example just to wet your appetite.
Fading backgrounds may no longer be the rage, but fading text in all likelihood will prove a lot more enduring. Below we will do with scripting what Java and Flash have been doing for ages - fade text gradually into view. Brought to you by the new DOM (Document Object Model) of IE5 and NS6.
General idea
Let's take a quick trip down memory lane. To change the document's background colour, the code to use is:
Oh yeah, haven't seen that in a long time. A background fade is created merely by incessantly calling this code to gradually change the colour from one extreme to another.
Moving on, dynamically changing the text's colour was historically never possible. The new DOM of IE5/NS6 changes that:
Here a textual element with ID "test" has its colour transformed to green.
Fading text technique
Believe it or not, the time is ripe to tackle the main subject. What we want is a script that continuously changes the text colour, so as to achieve that nifty fade effect. The trickiest part of it in our opinion is in fact figuring out the hexadecimal equivalent of colour values!
Demo:
Hello World
Notice how we can use rgb values to denote the colour, which comes in handy with the application at hand. By changing the value from 255 slowly to 0, we have a fade from white to black!
Fading colours other than black
Sometimes you may wish to fade from white to a colour other than black. A popular one is to blue, useful in fading in a text link, for example. Determining the hex equivalent of colours is definitely not a job intended for us humans. I suggest using one of the colour tools in the tools index.
Here is how the first fade works at the top of the page:
End of Tutorial






