An Introduction to Java Script By John Coliton
An Introduction to Java. Script By: John Coliton Tuesday, November 10, 1998 Center for Teaching and Learning
Java. Script Background • A Scripting Language • Designed to add interactivity to Web pages • Developed by Netscape as Live. Script – A proprietary feature of Netscape Browser – Late approved by Sun as official scripting language complement to JAVA
Java. Script 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.
Browser Compatibility • Java. Script 1. 0 – Netscape 2. x and I. E. 3. x • Java. Script 1. 1 – Netscape 3. x and some features in I. E. 3. x • Java. Script 1. 2 – Netscape 4. x and I. E. 4. x
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.
Hiding Scripts • Hide scripts from old browsers with comment tags. – – <!-- This is a comment in HTML --> //This is a comment in Java. Script • 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)
Checking for Compatibility • Script tag options: – <script language=javascript> • Browser must be at least Netscape 2. 0 or I. E. 3. 0 – <script language=javascript 1. 1> • Browser must be at least Netscape 3. 0 or I. E. 4. 0 – <script language=javascript 1. 2> • Browser must be at least Netscape 4. 0 or I. E. 4. 0
- Slides: 7