Since everyone in here is at least somewhat familiar with Visual Basic
the notion of writing code based on events is also familiar. The
ease of the ability to develop code based on a user's interaction with
some sort of form or window is a great plus for all of Microsoft's
development tools. These sorts of things are also possible in
other programming languages.
|onClick||This event occurs when a user clicks on a link.|
|onMouseOver||This is the technical name for the rollover event you have probably heard about.|
|onMouseOut||This is the technical name for the roll off event you have probably heard about.|
|Fortunately, unlike pure Java, you do not need to
invoke actionListeners and a lot of other paraphernalia in order to have
your pages interact with users. Now we will work a simple example
and after this has been presented we will discuss a couple syntactic
issues about quotes and dots.
What's Your Color? I'm pretty sure I remember hearing about concerned women going to some high class department stores so that they could find out what is the best make-up and clothing for their skin and hair color. I think it was called getting a color analysis. As someone who works quite hard to dodge the perfume sprayers at these high class department stores, when they are lax enough to let me in, you should have no doubt that we're about to improve on this scheme by about 100%. Our next task is to develop a computer program that will do this and more for you! Now, if I could just get someone to pay me money for this like they do in the department stores!
The code for the program is in the following table and should be called WhatsYourColor.html. While this brings to mind an old Monty Python sketch, I am likely to spare you the trauma of living through my rendition until you get to class.
<title>Determine Your Color</title>
|What this code actually does is not all that
Obviously, like so many things having to do with fashion and and making use of another's sense of style there is much in here that is really quite arbitrary.
After uploading this page and clicking on the link you should get something like the following.
|More About Dots and Quotes.
Now that you have experimented with what words give you colors you
really like, you may have noticed that much of this code looks like
<script></script> tags. What is different is that
Unfortunately, this leads to other difficulties with single quotes if you want them to appear literally in a string. An expression like
will run into problems because of the conflict between what's delimiting the string and what's used for apostrophes. What you would need to enter to get this to work would be the following.
Now onto the issue of all these dots. In the expression
the dots should be interpreted as the usual device used in object oriented programming to communicate containership and invoke properties and methods. The open window object (or window like object) contains a document object which has a bgColor property that should be set to the desired color.
We will see many more of these chains of containers, objects, properties and methods.