CSCI 107 — JavaScript notes and lab


This is far far far more than you need for CSCI 107.

JavasScript — history and examples

According to Turing award winner Barbara Liskov, JavaScript is what happens when you let amateurs design programming languages. This means it’s very messy.

In the beginning

Simple steps with JavaScript by local yokels

Doing something

Go to the lab.

Getting the starter files

Start by downloading a ZIPed copy of HTML, CSS, and JavaScript files and store it on your Desktop.

Open up Brackets and connect to the unZIPed directory, which should be called jslab_107_lab. Look at the three files.

The hook

The HTML file index.html loads both the CSS and JavaScript files. The CSS can be loaded in one tag; the JavaScript, in two. So strange.

<link href="shakespear.css" rel="stylesheet" type="text/css">
<script src="shakespear.js"><script>

Notice that index.html also contains class attributes for controlling style with CSS and style attributes for controlled mahem with JavaScript.

The style

The CSS file shakespear.css contains only two rule sets for changing the style of displayed HTML elements. CSS files often set the static style while JavaScript does the dynamic stuff.

The script

The JavaScript is contained in the file shakespear.js. If you want to really learn how to program in JavaScript, you need to sign up for CSCI 185, Internet Client-Side Tehnology.

Rather than explain this in gory detail on this page, I’m going to list four things the JavaSript does and give an explantion in class.

Doing something

Here are some tasks that will make an obnoxious web page. See if you can do some of them.