Inside JavaScript

Book description

The only comprehensive book available that covers the latest technology, such as Internet Explorer 6 and JavaScript 1.5, and JScript 5.6. Packed full of hands-on examples, this book integrates JavaScript with .NET, XML, XSLT, Java, CSS, HTML, Cookies, Security, and much more. Written for beginning to intermediate readers looking to learn how to work with JavaScript and how best to use it with other web technologies. Inside JavaSriptfills a void between the very beginning and high level books available in bookstores today. It's a book readers want primarily for two reasons: re-usable code and up-to-date browser information. Books currently out on the shelf are not up to the latest in browser technology; thus, frustrating readers because everything done in JavaScript is dependent on browser capabilities. The web site will contain all the source code used in the book.

Table of contents

  1. Copyright
    1. Dedication
  2. About the Author
  3. About the Technical Reviewers
  4. Acknowledgments
  5. Tell Us What You Think
  6. Introduction
    1. Who Should Read This Book
    2. Overview
    3. Conventions
  7. 1. Essential JavaScript
    1. JavaScript Through the Ages
    2. What’s JavaScript Good For?
    3. Creating Our First Script
      1. Choosing a Text Editor
      2. Selecting a Browser
      3. Creating Your Programming Environment
      4. Using HTML
      5. Adding Some JavaScript
    4. Dissecting Our First Script
      1. The <SCRIPT> Element
      2. Hiding Scripts from Older Browsers
      3. Using <NOSCRIPT>
      4. Writing JavaScript
      5. What About Semicolons?
      6. Commenting Your JavaScript
      7. Where Does the <SCRIPT> Element Go?
      8. Using Separate Script Files
      9. Specifying the Language Version
      10. When Does a Script Run?
      11. Inline Scripts
      12. Using <SCRIPT FOR>
    5. Viewing Script Errors
    6. Server-Side JavaScript
    7. Working with Browser Objects in JavaScript
    8. Browser Object Properties, Methods, and Events
    9. Handling Cross-Browser Programming Issues
      1. Cross-Browser Issues: Differing Object Models
      2. Cross-Browser Issues: Built-in JavaScript Objects
      3. Cross-Browser Issues: Core Language and Language Version
      4. Cross-Browser Issues: Which Browser Are You Using?
    10. JavaScript Resources You Should Know About
  8. 2. The JavaScript Language: Data, Operators, and Branching
    1. Working with Data
    2. Variables
      1. Naming Variables
      2. Initializing the Variable’s Data
      3. Where Do You Use the var Statement?
    3. Constants
    4. Working with Strings
    5. Data Conversions
    6. Arrays
      1. Accessing Array Data
      2. Determining the Array Length
    7. Operators
    8. Assignment Operators
    9. Arithmetic Operators
      1. The Increment Operator: ++
      2. The Decrement Operator: −−
      3. The Unary Negation Operator: −
    10. Comparison Operators
    11. Logical Operators
    12. String Operators
    13. Bitwise Operators
    14. Special Operators
      1. The Conditional Operator: ?:
      2. The Comma Operator: ,
      3. The delete Operator
      4. The in Operator
      5. The instanceof Operator
      6. The new Operator
      7. The typeof Operator
      8. The void Operator
    15. Understanding Operator Precedence
    16. Branching Statements
    17. The if Statement
      1. Omitting the Curly Braces
      2. Using else
    18. The switch Statement
  9. 3. The JavaScript Language: Loops, Functions, and Errors
    1. Loops
    2. The for Loop
      1. Using Local Variables in for Loops
      2. Using Arrays in for Loops
    3. The for…in Loop
    4. The while Loop
    5. The do…while Loop
    6. The with Statement
    7. Getting More Control: Ending and Continuing Loops
      1. Ending a Loop Early
      2. Continuing a Loop
      3. Using Labeled Statements
    8. Functions
      1. Returning Values
      2. Passing Values
      3. Passing by Reference Versus Passing by Value
      4. Handling Recursion
    9. All About Variable Scope
    10. The JavaScript Function Object
    11. The function Operator
    12. The this Keyword
    13. The JavaScript Built-in Functions
    14. Handling Errors
    15. Using the onerror Event Handler
    16. Using the try…catch Statement
      1. Unconditional catch Statements
      2. Conditional catch Statements
    17. Using the Error Object
    18. The finally Block
    19. Throwing an Exception Yourself
  10. 4. Handling the Browser Environment
    1. The Document Object Models: A History
      1. The DOM 0
      2. DOM 0+Images
      3. NS4 Extensions
      4. IE4 Extensions
      5. IE5 Extensions
      6. Version 6 Extensions
      7. The W3C DOM
      8. W3C DOM Nodes
      9. W3C DOM Node Properties, Methods, and Events
    2. The navigator Object
    3. The window Object
    4. The document Object
    5. The form Object
    6. The history Object
    7. The location Object
    8. HTML Elements
    9. Cross-Browser Programming
      1. Version Detection
      2. Object Detection
      3. Redirecting Browsers
      4. Creating Objects Based on Browser Type
      5. Using Script Libraries
    10. Accessing HTML Elements
    11. Accessing HTML Elements with the W3C DOM
  11. 5. Using Core HTML Properties
    1. From HTML Attributes to JavaScript Properties
    2. The accessKey Property
    3. The all Property
    4. The attributes Property
    5. The begin Property
    6. The behaviorUrns Property
    7. The canHaveChildren Property
    8. The canHaveHTML Property
    9. The childNodes Property
    10. The children Property
    11. The className Property
    12. The clientHeight, clientLeft, clientTop, and clientWidth Properties
    13. The contentEditable Property
    14. The currentStyle Property
    15. The dataFld, dataFormatAs, and dataSrc Properties
    16. The dir Property
    17. The disabled Property
    18. The document Property
    19. The end Property
    20. The filters Property
    21. The firstChild and lastChild Properties
    22. The hasMedia Property
    23. The height and width Properties
    24. The hideFocus Property
    25. The id Property
    26. The innerHTML, innerText, outerHTML, and outerText Properties
    27. The isContentEditable Property
    28. The isDisabled Property
    29. The isMultiLine Property
    30. The isTextEdit Property
    31. The lang and language Properties
    32. The length Property
    33. The localName, namespaceURI, and prefix Properties
    34. The nextSibling and previousSibling Properties
    35. The nodeName Property
    36. The nodeType Property
    37. The nodeValue Property
    38. The offsetHeight, offsetWidth, offsetLeft, offsetRight, and offsetParent Properties
    39. The onOffBehavior Property
    40. The ownerDocument Property
    41. The parentElement Property
    42. The parentNode Property
    43. The parentTextEdit Property
    44. The readyState Property
    45. The recordNumber Property
    46. The runtimeStyle Property
    47. The scopeName Property
    48. The scrollHeight, scrollWidth, scrollLeft, and scrollTop Properties
    49. The sourceIndex Property
    50. The style Property
    51. The syncMaster Property
    52. The tabIndex Property
    53. The tagName Property
    54. The tagUrn Property
    55. The timeContainer Property
    56. The title Property
    57. The uniqueID Property
  12. 6. Using Core HTML Methods and Events
    1. JavaScript’s Core HTML Methods
    2. Using JavaScript’s Core HTML Events
      1. Connecting an Event Handler Using Event Attributes
      2. Connecting an Event Handler Using Object Properties
      3. Connecting an Event Handler Using <SCRIPT FOR>
      4. Connecting an Event Handler Using the attachEvent Method
      5. Using event Objects
      6. Cross-Browser Event Handling
      7. Handling Events in the W3C DOM
    3. JavaScript’s Core HTML Methods
    4. The addBehavior Method
    5. The addEventListener Method
    6. The appendChild Method
    7. The applyElement Method
    8. The attachEvent Method
    9. The blur Method
    10. The clearAttributes Method
    11. The click Method
    12. The cloneNode Method
    13. The componentFromPoint Method
    14. The contains Method
    15. The detachEvent Method
    16. The dispatchEvent Method
    17. The dragDrop Method
    18. The fireEvent Method
    19. The focus Method
    20. The getAdjacentText Method
    21. The getAttribute Method
    22. The getAttributeNode Method
    23. The getBoundingClientRect Method
    24. The getClientRects Method
    25. The getElementsByTagName Method
    26. The getExpression Method
    27. The hasChildNodes Method
    28. The insertAdjacentElement Method
    29. The insertAdjacentHTML and insertAdjacentText Methods
    30. The insertBefore Method
    31. The item Method
    32. The mergeAttributes Method
    33. The normalize Method
    34. The releaseCapture Method
    35. The removeAttribute Method
    36. The removeAttributeNode Method
    37. The removeBehavior Method
    38. The removeChild Method
    39. The removeEventListener Method
    40. The removeExpression Method
    41. The removeNode Method
    42. The replaceAdjacentText Method
    43. The replaceChild Method
    44. The replaceNode Method
    45. The scrollIntoView Method
    46. The setActive Method
    47. The setAttribute Method
    48. The setAttributeNode Method
    49. The setCapture Method
    50. The setExpression Method
    51. The swapNode Method
    52. The tags Method
    53. The urns Method
    54. JavaScript’s Core HTML Events
    55. The onactivate, onbeforedeactivate, and ondeactivate Events
    56. The onbeforecopy Event
    57. The onbeforecut Event
    58. The onbeforeeditfocus Event
    59. The onbeforepaste Event
    60. The onblur Event
    61. The onclick Event
    62. The oncontextmenu Event
    63. The oncontrolselect Event
    64. The oncopy Event
    65. The oncut Event
    66. The ondblclick Event
    67. The ondrag, ondragend, ondragenter, ondragleave, ondragover, ondragstart, and ondrop Events
    68. The onfilterchange Event
    69. The onfocus Event
    70. The onfocusin and onfocusout Events
    71. The onhelp Event
    72. The onkeydown, onkeypress, and onkeyup Events
    73. The onlosecapture Event
    74. The onmousedown, onmouseenter, onmouseleave, onmousemove, onmouseout, onmouseover, onmouseup, and onmousewheel Events
    75. The onmove, onmoveend, and onmovestart Events
    76. The onpaste Event
    77. The onpropertychange Event
    78. The onreadystatechange Event
    79. The onresize, onresizeend, and onresizestart Events
    80. The onselectstart Event
    81. The ontimeerror Event
  13. 7. Using window and frame Properties
    1. Properties of the window Object
    2. Accessing the Status Bar
    3. Working with New Windows
    4. Creating Dialog Boxes
    5. Using the Clipboard
    6. The screen Object
    7. Setting the Netscape Navigator’s Dimensions
    8. Displaying and Hiding Netscape Navigator Bars
    9. Working with Frames
    10. The <FRAMESET> Element
    11. The <FRAME> Element
      1. Using Frame Properties
      2. Insisting on Frames
      3. Avoiding Framing
      4. Creating Frames in JavaScript: JavaScript URLs
    12. The <IFRAME> Element
  14. 8. Using window and frame Methods and Events
    1. Alerts, Confirmations, and Prompts
    2. Creating Popups
    3. Moving Windows
    4. Opening and Closing New Windows
    5. Working with Other Windows
    6. Printing
    7. Scrolling a Window
    8. Creating Timed Events
    9. Dialog Boxes
    10. Window Loading and Unloading
    11. Methods and Events of the <FRAMESET> Element
    12. Methods and Events of the <FRAME> Element
    13. Methods and Events of the <IFRAME> Element
  15. 9. Using the document and body Objects
    1. The <HTML>, <HEAD>, and <TITLE> Elements
    2. The document Object Properties
    3. The document Object Collections
    4. Setting Colors
    5. Creating Cookies
    6. Handling File Dates and Sizes
    7. Tracking User Navigation
    8. The document Object Methods
    9. Getting Selected Text
    10. Creating New Elements and Nodes
    11. Using execCommand
    12. Writing to a Document
    13. Finding Elements by Location
    14. The document Object Events
    15. Using onstop
    16. The <BODY> Element
    17. The Properties of the <BODY> Element
    18. The Methods of the <BODY> Element
    19. Using doScroll
    20. The Events of the <BODY> Element
  16. 10. Using the navigator, location, and history Objects
    1. The navigator Object
    2. The navigator Object’s Properties
    3. Using the browserLanguage, systemLanguage, and userLanguage Properties
    4. Using the userAgent Property
    5. Detecting Browser and Version
    6. The navigator Object’s Methods
    7. Setting Netscape Navigator Preferences
    8. The location Object
    9. The location Object’s Properties
    10. Using the location Object’s Properties
    11. Navigating to a New URL
    12. Redirecting a Browser
    13. The location Object’s Methods
    14. The history Object
    15. The history Object’s Properties
    16. The history Object’s Methods
    17. Using the go, forward, and back Methods
  17. 11. Working with HTML Text Elements
    1. The <BLOCKQUOTE> Element
    2. The <BR> Element
    3. The <FONT> Element
    4. The <H1>-<H6> Heading Elements
    5. The <HR> Element
    6. The <LABEL> Element
    7. The <MARQUEE> Element
    8. The <Q> Element
    9. The TextRange Object
    10. Creating Text Ranges
    11. Finding and Replacing Text
    12. Selecting Text
    13. The selection Object
    14. The Range Object
    15. Using Ranges
    16. Text Nodes
  18. 12. Working with Forms, Buttons, Check Boxes, and Radio Buttons
    1. The <FORM> Element
    2. Using Forms
    3. Submitting Forms
    4. Submitting Forms Yourself
    5. Emailing Forms
    6. Passing Forms to Functions
    7. Buttons
    8. Using Buttons
    9. Clicking a Button from Code
    10. Resetting Button Captions
    11. Check Boxes and Radio Buttons
    12. Using Check Boxes
    13. Using Radio Buttons
    14. The <FIELDSET> and <LEGEND> Elements
  19. 13. Working with Text and Select Controls
    1. The <INPUT TYPE=“TEXT”>, <INPUT TYPE= “PASSWORD”>, and <INPUT TYPE= “HIDDEN”> Elements
    2. Using Text Controls
    3. The <TEXTAREA> Element
    4. Using Text Areas
    5. The <SELECT> Element
    6. Using <SELECT> Controls
    7. Creating New Options in a <SELECT> Control
    8. The <OPTGROUP> Element
    9. Using the <OPTGROUP> Element
    10. The File Upload Element <INPUT TYPE=“FILE”>
    11. Using the File Upload Element
  20. 14. Working with Links, Lists, and Tables
    1. The <A> Element: Hyperlinks and Anchors
    2. Using Hyperlinks
      1. Using JavaScript URLs
    3. The <OL> Element: Ordered Lists
    4. The <UL> Element: Unordered Lists
    5. The <LI> Element: List Items
    6. The <DL>, <DT>, <DD>, <DIR>, and <MENU> Elements
    7. Using Lists
    8. The <TABLE> Element: Creating Tables
    9. The <TR> Element
    10. The <TD> and <TH> Elements
    11. The <TBODY>, <TFOOT>, and <THEAD> Elements
    12. The <CAPTION> Element
    13. The <COL> and <COLGROUP> Elements
    14. Using Tables
  21. 15. Working with the Mouse, Keyboard, and Images
    1. Working with Events
    2. The Mouse
    3. The Keyboard
    4. The <IMG> Element
    5. Using Images
    6. Mouse Rollovers
    7. Precaching Images and the Image Object
    8. Moving Images
    9. Image Maps
    10. Handling Events
    11. The NS4 event Object
    12. Using the NS4 event Object
    13. The IE4+ event Object
    14. Using the IE4+ event Object
    15. The NS6+ event Object
  22. 16. Dynamic HTML: Changing Web Pages On-the-Fly
    1. Dynamic HTML in Internet Explorer
    2. Dynamic HTML in Netscape Communicator
    3. Changing Properties
    4. Dynamic Styles
    5. Self-Modifying Pages Using document.write
    6. The insertAdjacentHTML and insertAdjacentText Methods
    7. The innerHTML, innerText, outerHTML, and outerText Properties
    8. Using Text Ranges
    9. The <LAYER> Element
      1. Layers and the Mouse
      2. Moving Layers On-the-Fly
    10. Setting Element Visibility On-the-Fly
    11. Creating New Elements
    12. Filters
    13. Vector Markup Language
    14. Visual Transitions
    15. Internet Explorer Direct Animation
  23. 17. Dynamic HTML: Drag and Drop, Data Binding, and Behaviors
    1. Dragging and Dropping Visual Elements
    2. Dragging and Dropping Data
    3. Dragging and Dropping Using Layers
    4. Data Binding
    5. Using the MSHTML Control
    6. Using the Tabular Data Control
    7. Using the XML DSO
    8. Internet Explorer Behaviors
      1. Attaching Behaviors to Events
      2. Creating Behavior Properties, Methods, and Events
      3. Using Default Behaviors
  24. 18. The Date, Time, and String Objects
    1. The Date Object
    2. Working with the Date Object
      1. Creating an Alarm Clock
      2. Adding and Subtracting Dates
      3. Handling Date Strings
      4. Checking Date Format
      5. Creating Custom Date Strings
    3. The String Object
    4. Working with the String Object
      1. Changing Case
      2. Formatting Text
      3. Splitting Strings
      4. Searching Strings
      5. Searching and Replacing
  25. 19. The Math, Number, Boolean, and Array Objects
    1. The Math Object
    2. Using the Math Object
      1. Performing Calculations
      2. Random Numbers
      3. Finding Absolute Values and Rounding Down
    3. The Number Object
    4. Using the Number Object
      1. Setting Precision
      2. Determining Maximum and Minimum Possible Values
      3. Using the prototype Property
    5. The Boolean Object
    6. Using the Boolean Object
    7. The Array Object
    8. Using the Array Object
      1. Initializing Arrays
      2. Sorting Arrays
      3. Multidimensional Arrays
      4. Pushing and Popping
  26. 20. The RegExp Object: Working with Regular Expressions
    1. Finding Matches
    2. Replacing Text
    3. Creating Regular Expressions
    4. Regular Expressions: Characters
      1. Matching Any Character
    5. Regular Expressions: Character Classes
    6. Regular Expressions: Alternative Match Patterns
    7. Regular Expressions: Quantifiers
    8. Regular Expressions: Assertions
    9. Regular Expressions: Backreferences
    10. Regular Expressions: Regular Expression Extensions
    11. Using Modifiers
    12. Matching Words
    13. Matching Numbers
    14. Quantifier Greediness
    15. Removing Leading and Trailing White Space
    16. Regular Expression Objects
    17. The RegExp Object
  27. 21. Cascading Style Sheets and CGI Programming
    1. Inline Styles
    2. Embedded Style Sheets
    3. External Style Sheets
    4. Style Classes
    5. Using Font Styles: Font, Font Size, Font Weight, Font Style
    6. Using Colors and Backgrounds
    7. Using Margin, Indentation, and Alignment Styles
    8. Using Hyperlink Styles
    9. Using Absolute Positioning
    10. Using Relative Positioning
    11. Style Specifications
    12. Background and Color Attributes
    13. Positioning and Block Attributes
    14. HTML Element Box Attributes
    15. Font Attributes
    16. Text Attributes
    17. Visual Effect Attributes
    18. Text Mouse Rollovers
    19. Changing Style Classes On-the-Fly
    20. Changing Style Sheets On-the-Fly
    21. Changing Mouse Cursors
    22. Showing and Hiding Elements
    23. Menus
  28. 22. XML and XSLT
    1. XML
    2. Accessing XML Documents
    3. Using XML Data Islands
    4. Accessing XML Elements by Name
    5. Accessing Attribute Values in XML Elements
    6. Parsing XML Documents in Code
    7. Handling XML Document Events
    8. Validating XML Documents
    9. XSLT
  29. 23. Cookies and Creating Your Own Objects
    1. Cookies
    2. Creating Cookies
    3. Reading Cookies
    4. Deleting Cookies
    5. Self-Modifying Pages That Respond to Cookie Data
    6. Accessing the Disk
    7. Creating Custom Objects: Properties
    8. Setting Default Property Values
    9. Creating Custom Objects: Methods
    10. Sorting Arrays of Custom Objects
    11. The JavaScript Object Object
    12. Using the JavaScript Object Object
    13. Adding Properties to Existing Objects
    14. Adding Methods to Existing Objects
  30. 24. .NET and Security
    1. .NET and JavaScript
    2. Perl and JavaScript
    3. Perl and HTML Controls
      1. Setting Up the Form
      2. Using Text Fields
      3. Using Text Areas
      4. Using Check Boxes
      5. Using Select Controls
      6. Using Radio Buttons
      7. Using Password Controls
      8. Using Drop-Down Lists
      9. Using Hidden Data Fields

Product information

  • Title: Inside JavaScript
  • Author(s):
  • Release date: August 2002
  • Publisher(s): New Riders
  • ISBN: 9780735712850