an introduction to javascript by: john coliton tuesday, november 10, 1998 center for teaching and...

7
An Introduction to JavaScript By: John Coliton Tuesday, November 10, 1998 Center for Teaching and Learning

Upload: barnard-quinn

Post on 05-Jan-2016

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: An Introduction to JavaScript By: John Coliton Tuesday, November 10, 1998 Center for Teaching and Learning

An Introduction to JavaScript

By: John Coliton

Tuesday, November 10, 1998

Center for Teaching and Learning

Page 2: An Introduction to JavaScript By: John Coliton Tuesday, November 10, 1998 Center for Teaching and Learning

JavaScript Background

• A Scripting Language

• Designed to add interactivity to Web pages

• Developed by Netscape as LiveScript– A proprietary feature of Netscape Browser– Late approved by Sun as official scripting

language complement to JAVA

Page 3: An Introduction to JavaScript By: John Coliton Tuesday, November 10, 1998 Center for Teaching and Learning

JavaScript Pros and Cons

• Designed to be executed by browser– No special compiler needed– Code typed directly into HTML document– Easy to create scripts– Easy to copy other scripts (or be copied)

• Fully supported by Netscape - not I.E.

Page 4: An Introduction to JavaScript By: John Coliton Tuesday, November 10, 1998 Center for Teaching and Learning

Browser Compatibility

• JavaScript 1.0– Netscape 2.x and I.E. 3.x

• JavaScript 1.1– Netscape 3.x and some features in I.E. 3.x

• JavaScript 1.2– Netscape 4.x and I.E. 4.x

Page 5: An Introduction to JavaScript By: John Coliton Tuesday, November 10, 1998 Center for Teaching and Learning

Where to Put Scripts

• HEAD section of HTML– Stored in a script and ignored by browser until

“called” by body

• BODY section of HTML– Executed immediately in a script– Executed later in an “event” handler like a

mouse click or selecting a button on a form.

Page 6: An Introduction to JavaScript By: John Coliton Tuesday, November 10, 1998 Center for Teaching and Learning

Hiding Scripts• Hide scripts from old browsers with comment

tags.– <!-- This is a comment in HTML --> – //This is a comment in JavaScript

• Used together they can hide most anything– <script> (Older browsers ignore this tag)– <!-- (script ignores comment mark)– // --> (ends comment but hides from script)– </script> (ends script)

Page 7: An Introduction to JavaScript By: John Coliton Tuesday, November 10, 1998 Center for Teaching and Learning

Checking for Compatibility

• Script tag options:– <script language=javascript>

• Browser must be at least Netscape 2.0 or I.E. 3.0

– <script language=javascript1.1>• Browser must be at least Netscape 3.0 or I.E. 4.0

– <script language=javascript1.2>• Browser must be at least Netscape 4.0 or I.E. 4.0