Chapter 13. JavaScript in Web Browsers


The first part of this book described the core JavaScript language. Part II moves on to JavaScript as used within web browsers, commonly called client-side JavaScript.[*] Most of the examples you've seen so far, while legal JavaScript code, have no particular context; they are JavaScript fragments that run in no specified environment. This chapter provides that context. It starts with an overview of the web browser programming environment. Next, it discusses how to actually embed JavaScript code within HTML documents, using <script> tags, HTML event handler attributes, and JavaScript URLs. These sections on embedding JavaScript are followed by a section that explains the client-side JavaScript execution model: how and when web browsers run JavaScript code. Next are sections that cover three important topics in JavaScript programming: compatibility, accessibility, and security. The chapter concludes with an short description of web-related embeddings of the JavaScript language other than client-side JavaScript.

[*] The term client-side JavaScript is left over from the days when JavaScript was used in only two places: web browsers (clients) and web servers. As JavaScript is adopted as a scripting language in more and more environments, the term client-side makes less and less sense because it doesn't specify the client side of what. Nevertheless, I'll continue to use the term in this book.

When JavaScript is embedded in a web browser, the browser exposes a powerful and diverse set of capabilities and allows them to be scripted. The chapters that follow Chapter 13 each focus on one major area of client-side JavaScript functionality:

  • Chapter 14, Scripting Browser Windows, explains how JavaScript can script web browser windows by, for example, opening and closing windows, displaying dialog boxes, causing windows to load specified URLs, or causing windows to go back or forward in their browsing history. This chapter also covers other, miscellaneous features of client-side JavaScript that happen to be associated with the Window object in client-side JavaScript.

  • Chapter 15, Scripting Documents, explains how JavaScript can interact with the document content displayed within a web browser window and how it can find, insert, delete, or alter content within a document.

  • Chapter 16, Cascading Style Sheets and Dynamic HTML, covers the interaction of JavaScript and CSS and shows how JavaScript code can alter the presentation of a document by scripting CSS styles, classes, and stylesheets. One particularly potent result of combining scripting with CSS is Dynamic HTML (or DHTML) in which HTML content can be hidden and shown, moved, and even animated.

  • Chapter 17, Events and Event Handling, explains events and event handling and shows how JavaScript adds interactivity to a web page by allowing it to respond to a user's input.

  • Chapter 18, Forms and Form Elements, covers forms within HTML documents and shows how JavaScript can gather, validate, process, and submit user input with forms.

  • Chapter 19, Cookies and Client-Side Persistence, shows how JavaScript scripts can persistently store data using HTTP cookies.

  • Chapter 20, Scripting HTTP, introduces HTTP scripting (commonly known as Ajax) and demonstrates how JavaScript can communicate with web servers.

  • Chapter 21, JavaScript and XML, shows how JavaScript can create, load, parse, transform, query, serialize, and extract information from XML documents.

  • Chapter 22, Scripted Client-Side Graphics, demonstrates common JavaScript image-manipulation techniques that can create image rollovers and animations in web pages. It also demonstrates several techniques for dynamically drawing vector graphics under JavaScript control.

  • Chapter 23, Scripting Java Applets and Flash Movies, explains how JavaScript can interact with Java applets and Flash movies embedded in a web page.




JavaScript. The Definitive Guide
JavaScript: The Definitive Guide
ISBN: 0596101996
EAN: 2147483647
Year: 2004
Pages: 767

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net