CS 203 - Javascript Lab 1
Due within 5 days of lab period
For your first Javascript experience, write a new html page. Since
Javascript is executed by the client,
there is no need to transfer this page to Osiris. In fact, what I
ask you to do might make the page extremely annoying to your
visitors! Send it with the form below.
Please try at least the following:
- Javascript objects have both methods (functions) and
properties (data). Your page is the document object. Use its write() method to write its
lastModified property.
(This is handy to show how up-to-date your html page is.)
- A new Date() object can be created. Write your birthday or
other significant event. You'll find out what day of the week it
is. You have to use new
and assign it to a variable. Examples:
- var now = new Date() ; // is right now
- var xmas = new Date(2024,11,25) ; // is Christmas.
(Months are numbered from 0)
- There are
days until Christmas (view source to see
the calculation)
- Change the style of some page element, using on-event in some
tag, for example (look at the header of this page)
onmouseover="this.style.color='red'"
- Use one of the popups: alert(),
confirm() or prompt()
and write corresponding content in your page. For example:
- Ask for name, and write it in a header
- onClick of an
image, pop up something about it (who or what it is)
- Write either a funny or profound saying, depending upon the
answer to a question using confirm()
- When a text field is changed, alert if it is now blank onChange
- (Science Students) Do
a second one of these popups.
- (Computer Science students)
Show a sentence in one of at least 2 languages, depending
upon what is clicked (link, button, or radio button). This
can be shown in an input
of type text, or more elegantly in a paragraph or other named
(or id'd) element, by setting its innerHTML property. See at the
end of my expand_contract
example on osiris.
Remember, JavaScript goes
between script tags, and is sent by the server as-is to the client.
The <noscript> tag is important, since some people disable
Javascript, especially when annoyed
<script type="text/javascript">
// javascript statements here
</script>
<noscript>
This will appear if javascript is disabled
</noscript>
HTML here will just be printed
<img onClick="also javascript here "
src="me.gif">
Send me your file here
If you have a jpeg image, use this form again to send it
Document last modified
, by Lin Jensen