Dynamin Web Pages with JavaScript

The Document Object

The document object represents the whole document. Like other objects that represent real-world things, the document object has:

How a Browser Sees a Web Page

  1. The browser receives a page as HTML code
  2. It creates a model of the page and store it in a memory
  3. It shows a page on the screen using a rendering engine
  4. All major broswers use a JavaScript interpreter (or scripting engine) to translate your instructions (in JavaScript) so the computer can follow

How do computers fit in with the world around them?

How Do I Write a Script for a Web Page?

How HTML, CSS & JavaScript Work Together

Aim to keep these three languages in separate files, with the HTML page linking to the CSS and JavaScript files. Each language forms a separate layer with a different purpose.

HTML

CONTENT LAYER

HTML gives the page structure and adds semantics

CSS

PRESENTATION LAYER

CSS enhances the HTML page with rules that state how the HTML content is presented

JavaScript

BEHAVIOR LAYER

JavaScript adds interactivity to the web page

Basic JavaScript Instructions

Statements

A script is a series of instructions that a compuer can follow one-by-one

Comments

A comment explains what the code does to help make the code easier for you to read and understand

Variables

A script will have to temporarily store the bits of information it needs to do its job. It can store this data in variables.

How to assign variables a value

The equal sign is an assignment operator. It says that you are going to assign a value to the variable. Until then, it is undefined.

Data Types