You are previewing JavaScript™ 1.5 by Example.
O'Reilly logo
JavaScript™ 1.5 by Example

Book Description

JavaScript 1.5 by Example starts with a taste of JavaScript – what it is, what it¿s for, and what readers need to get started. The book then explains how to add JavaScript to existing HTML pages, leading readers into the fundamentals of the language including JavaScript syntax, notation and conventions, communicating with users via input and output, manipulating variables and data, logic statements in JavaScript, and object programming with JavaScript. The book progresses to an explanation of JavaScript¿s role in Dynamic HTML, and how that power can be exploited to create animation, navigation, forms processing and more.

Table of Contents

  1. Copyright
  2. About the Author
  3. Acknowledgments
  4. Tell Us What You Think!
  5. Introduction
  6. Welcome to JavaScript
    1. Getting into JavaScript!
      1. JavaScript Is Everywhere
      2. Why You Need to Learn JavaScript
      3. JavaScript History
      4. JavaScript Today
      5. The Future of JavaScript
      6. What Is the Difference Between a Script and a Program?
      7. What About the Difference Between a Scripting Language and a Programming Language?
      8. Tools for the JavaScripter
      9. Having the Latest Browsers
      10. Other Tools
      11. What's Next
    2. Combining JavaScript and HTML
      1. Meeting of Worlds—HTML and JavaScript
      2. Hiding JavaScript from Older Browsers
      3. What's Next
  7. Language Tour
    1. JavaScript in Action
      1. Exploring JavaScript Inputs and Outputs
      2. Objects, Methods, … and Even Properties
      3. Using the alert() Method
      4. Adding Comments to JavaScript
      5. Using the confirm() Method
      6. Using the prompt() Method
      7. What's Next
    2. Handling Data with Variables
      1. JavaScript Values
      2. JavaScript Variables
      3. Troubleshooting!
      4. Using the prompt() Method to Assign a Value to a Variable
      5. What's Next
    3. JavaScript Arrays and Escape Characters
      1. Using Arrays
      2. Creating an Array in a Hurry!
      3. The Length of an Array
      4. Showing All Elements
      5. Exercise—Interactive Story
      6. Escape Characters
      7. What's Next
    4. Expressions, Conditions, Operators, and More Strings and Numbers
      1. More on Terminology—What Are Expressions and Conditions?
      2. Introducing Operators
      3. Revisiting Strings and Numbers
      4. What's Next
    5. Using Statements in JavaScript
      1. What Are Statements?
      2. The variable Statement
      3. The if Statement
      4. Iteration Statements
      5. The continue Statement
      6. The break Statement
      7. The switch Statement
      8. What's Next
    6. Write Better JavaScript Scripts by Using Functions and Events
      1. What Are Functions?
      2. Your First Function
      3. Events
      4. Using Events
      5. Creating Effective Functions!
      6. Functions Running Functions!
      7. What Are Those Parentheses For?
      8. Using Parameters Between Functions
      9. The return Statement
      10. Exercise—Temperature Conversion JavaScript
      11. What's Next
    7. Getting the Most Out of Objects
      1. Objects—What Are They?
      2. Objects and Browsers
      3. The JavaScript Objects—A Closer Look
      4. The Math Object
      5. The Date Object
      6. The String Object
      7. The with Statement
      8. Object Methods and Properties
      9. What's Next
    8. Bugs—How to Find Them and Kill Them
      1. What Are Bugs?
      2. Types of Bugs
      3. Finding Errors
      4. Narrowing Down Errors
      5. The Microsoft Script Debugger
      6. Common Errors
      7. What's Next
  8. Where Does JavaScript Go?
    1. Going Beyond the Box (or Should That Be Head?)
      1. Thinking Outside the <head>!
      2. Linking, Linking, Linking!
      3. Inline JavaScript
      4. When to Use Your <head>, When to Link, and When to Make It Inline!
      5. What's Next
  9. JavaScript and Dynamic HTML
    1. Dynamic HTML and JavaScript
      1. The World of DHTML
      2. The Concepts and Features of DHTML
      3. Why Do Differences Exist Between the Browsers?
      4. What Can You Do with DHTML?
      5. What's Next
    2. Cascading Style Sheets and JavaScript!
      1. A Little Cascading Style Sheets History
      2. Introduction to CSS
      3. JavaScript and CSS
      4. Creating Animation!
      5. Animation and Internet Explorer 5
      6. Doing the Same Thing … Only in Netscape Navigator 4!
      7. Making It Work in Both Browsers!
      8. Ups and Downs
      9. Want to Go Diagonally?
      10. Back to JavaScript for a Moment…
      11. What's Next
    3. JavaScript and the Document Object Model
      1. An Introduction to the Document Object Model
      2. How Much Power Does It Give Me?
      3. Access to Page Elements
      4. The Event Model
      5. JavaScript Power
      6. What's Next
    4. Examples, Examples, Examples!
      1. Example 1—Adding Last Modified Dates to Web Pages
      2. Example 2—Simple Clock
      3. Example 3—Simple Countdown Counter
      4. Example 4—Simple Form Validation
      5. Example 5—Rollovers
      6. Example 6—Scrolling Status Bar Message
      7. Example 7—Controlling Cookies
      8. What's Next
  10. Index