Time | IF | Date Object | Arrays | Avoid the work | Hide email | Random | Intigrate HTML | Test
If you have trouble understanding how JavaScript works I will attempt to explain it on these pages.
This will not be a place to get all the latest cut and paste scripts. There are lots of places on the web for that. Try Dynamic Drive
This is merely intended to take the mystery out of the subject.
There are many ways to use JavaScript to make things easier on yourself.
For instance :
I actually made my web page about my dog Buster several years ago and although he has now passed away his age and time of his mishap are still current because I used a little JavaScript
This is a part of what I wrote.
This makes use of one of the basics of JavaScript - Time.
You will see the JavaScript Date Object (That is what it is called )used on many pages giving you the time of day in several different formats but what use is that really.
We already knew what time it was before we entered the page.
Understanding the time object and using it to keep your text current is only one of the much more practical ways to use it.

Since I started with time let me go through the way to use it and in doing so you will learn some of the most important parts of JavaScript.

First all JavaScript must be contained by the JavaScript tag just like all HTML.
<Script Language="JavaScript">
<!--
//-->
</Script>
The <!-- and //--> are in there to hide the script from old browsers
Probably no longer needed but just put it in and forget it is there.

Next you need to be able to make JavaScript print something on your page.
This is done with 'document.write( )' ( Even easy to remember the name )
document.write
(
'My first JavaScript text'
)
I have put each part on a new line for clarity but this could be written
document.write( 'My first JavaScript text' )
Pulling it apart we see that document.write ( ) will print whatever is between the brackets that always follow it ( )
What it writes must be in parentheses (either double " " or single ' ' but they must match )unless it is printing a variable which we come to next.
To review this is how the previous script will look in its entirity.
<Script Language="JavaScript">
<!--
document.write
(
'My first JavaScript text'
)
//-->
</Script>



An important note about parentheses :
When JavaScript finds the first ' or " it will look for the next one to complete the entry.
This makes it possible to put the opposite parentheses within the text like this.
<Script Language="JavaScript">
<!--
document.write
(
'My first "JavaScript" text'
)
//-->
</Script>


Next : Time

Home