Download Classifications of Languages - Introduction to Java Script - Lecture Slides and more Slides Javascript programming in PDF only on Docsity!
Introduction to JavaScript
Classifications of Languages
- High-Level vs Low Level
- Remember that Information Technology is VERY layered
- Compiled vs Interpreted
- Structured vs Object Oriented
- Scripting vs Programming
Web Scripting Languages
- Combine PL tools to make easier to use
- Fewer features
- Less versatile
- Can be client side or Server side
- Server side –
- Invoked from browser
- Run on the server
- Client side - JavaScript
- Invoked and Run on the browser
JavaScript
- Extends functionality of Web pages
- Written in the HTML Document
- Controls page elements
- Reacts to user actions
- Instructions - code downloaded as text
- Platform independent
- Object Oriented
Object Examples
Object Attribute Things it can do
Computer Brand name Model Name Processor Type Processor Speed Disk Drive
Boot up Run an application Perform math calculations Shut down
Disk Drive Brand name Model name Storage capacity Transfer rate Access time
Store information Retrieve information Delete information
JavaScript Object Example
Object Attribute Things it can do
document bgColor linkColor vlinkColor title
clear() close() writeln() write()
- To Reference Properties and methods
- document.title
- document.bgColor
- document.writeln(My Heading)
JavaScript Variables
- Variables: containers for data
- All variables have
- Name
- Type – JavaScript is loosely typed
- Value or “null”
- To declare a variable
- Beware of reserved words (book page 558)
The Document Object Model
objects on a web page
web browser objects
Netscape, Microsoft
standard DOM by W3C
A Word About Comments
- JavaScript Comments
- These comments must be within a script
- // begins a single line comment
- These can start anywhere on the line, but the remainder of the line becomes a comment
- /* All of your comments here… */
- Everything between the start and end comment markers are comments
- Can be on a single line or span many…
HTML Comments
JavaScript in HTML, Template
** My page with javascript
the page requires a browser with javascript ...**
Events and Functions
- Many event handlers are supported
- onmouseover, onmouseout, onclick
- …/swap image.html
- Functions have Three parts
- The function keyword
- Parenthesized, comma-separated list of arguments
- Statements enclosed in curly brackets
- …/function ex.html
Attributes and Reusable code
- You can pass attribute to a function
- Use the src attribute of the