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 ...
Get JavaScript: The Definitive Guide, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.