Chapter 14. Scripting Browser Windows


Chapter 13 described the Window object and the central role it plays in client-side JavaScript: it is the global object for client-side JavaScript programs. This chapter explores the properties and methods of the Window object that allow you to control the browser and its windows and frames.

Here, you'll find out how to:

  • Register JavaScript code to be executed in the future, either once or repeatedly

  • Get the URL of the document displayed in a window and parse query arguments out of that URL

  • Make the browser load and display a new document

  • Tell the browser to go back or forward in its history and learn to control other browser functions such as printing

  • Open new browser windows, manipulate them, and close them

  • Display simple dialog boxes

  • Determine what browser your JavaScript code is running in and obtain other information about the client-side environment

  • Display arbitrary text in the status line of a browser window

  • Handle uncaught JavaScript errors that occur in a window

  • Write JavaScript code that interacts with multiple windows or frames

You'll notice that this chapter is all about manipulating browser windows but does not have anything to say about the content displayed within those windows. When JavaScript was young, document content was scriptable only in very limited ways, and the window scripting techniques described in this chapter were exciting and fresh. Today, with fully scriptable documents (see Chapter 15), scripting the browser is no longer cutting-edge. Furthermore, some of the techniques shown in this chapter are hampered with security restrictions and do not function as well as they once did. Other techniques still function, but have fallen out of favor with web designers and are no longer commonly used.

Although this chapter is less relevant today, it is not altogether irrelevant, and I do not recommend that you skip it. The chapter is organized so that (most of) the most important material comes first. This is followed by less important or less commonly used techniques. One important, but more complicated, section on the use of JavaScript to interact with multiple windows and frames is deferred until the end of the chapter, and the chapter concludes with a useful example.




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