It can also display today's date and time in many different formats:
It can put scrolling text on your page:
It can put a drop down menu on your page:
This menu has been disabled but you will will learn how to do the real thing is this class.
It can get basic information about your visitor and his Browser:
It can do some cool things with images, such as a rollover:
It can do pop-up windows:
It is fast:
It can be mixed with HTML:
It can be annoying to your visitors:
It can be frustrating to develop:
When you make a mistake and try to trouble shoot. But so can HTML! Have you ever left off a closing tag such as </FONT> and spent some time trying to find the mistake among the many tag combinations on your page.
It is Object Oriented:
It is not Java:
It is called jscript by Microsoft:
the following HTML code. We will add to it and eventually wind up with a
working clock similar to the one above. Of course it will take us a
several lessons to get there because we first need to learn the basics.
following script after the line <P>Today is
As a quick review, a simple HTML tag has the following syntax:
Ok, add the two necessary lines to our first script to hide it from
older browsers. Our completed html code should now look that shown below.
Make sure that you reload the script in the browser to prove that it still
works the same.
Here is a sample of how the error will look on the Netscape and Internet Explorer browsers. Yours may vary a little from this.
Microsoft Internet Explorer 4
Microsoft Internet Explorer 5
Notice that all of the error messages show a line number that the error occurred on. In our simple case the line number is exactly where the error occurred. This will not always be the case as our scripts get more complex. However, it will give you some clue as to where to start looking. The error call out can be a little confusing and needs some getting use to.
You probably want to change the case for "document.write" back to all small letters in our example script, save it and make sure it runs ok before we proceed further.
The document.write() method is one that you will be using a lot.
For now, don't worry too much about what a method is beyond our basic
We will explain that and why you see the period between the words document
and write during lesson 7. Just realize that you can use this method to
write a string to the document while it is loading. The syntax for the
document.write() method is
So, what is a string? As we will learn in lesson 4, it is nothing more than a series of characters. You put the characters in quote marks, except when the string is something that is returned by another method, which was the case in our first script, or is a variable which you will also learn about in lesson 4.
So if we wanted to write Welcome to my Web Page using document.write(), this is how we
would do it:
Now suppose we want to use document.write() to insert an image in the document.
Normally we would use the <IMG> tag to do this. For instance, the
tag would look something like this if we were inserting our pet's picture
Don't forget that you must put our above example scripts between the <SCRIPT> </SCRIPT> tags for them to work.
So are you completely confused yet? If you can
[ Top of Page | Contents ]