Name
Window — a web browser window, tab, or frame
Inherits from
EventTarget
Synopsis
The Window object represents a browser window, tab, or frame. It is
documented in detail in Chapter 14. In client-side
JavaScript, the Window serves as the “global object,” and all
expressions are evaluated in the context of the current Window
object. This means that no special syntax is required to refer to
the current window, and you can use the properties of that window
object as if they were global variables. For example, you can write
document rather than .
Similarly, you can use the methods of the current window object as
if they were functions: e.g., window.documentalert() instead of .window.alert()
Some of the properties and methods of this object actually query or manipulate the browser window in some way. Others are defined here simply because this is the global object. In addition to the properties and methods listed here, the Window object also implements all the global properties and functions defined by core JavaScript. See Global in Part III for details.
Web browsers fire many kinds of events at windows. This means that the Window object defines quite a few event handlers, and that Window objects implement the methods defined by EventTarget.
The Window object has window and self properties that refer to the window
object itself. You can use these to make the current window
reference explicit rather than implicit.
A Window can contain other Window objects, typically in the
form of <iframe> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access