JavaScript Window Properties

About This Index
This page is the JavaScript Window Properties index for the tutorial track. Each row links to a short property guide. Open a row to read syntax, examples, and FAQs.
Learn what the window is on /js/window. Functions such as alert() and setTimeout() are on the methods index.
window.innerWidth is a number. window.closed is true or false. window.innerWidth() throws.
How to Read a Window Property
Properties are values. No parentheses:
window.self === window; // true
window.closed; // false while the tab is open
window.innerWidth; // viewport width
window.scrollY; // pixels scrolled down
window.location.href; // full URL
window.localStorage; // Storage for this origin JavaScript Window Properties Table
Properties you read on window in this JavaScript tutorial (21 entries).
This window and its frames
8 propertiesRead these on window to see which window you are in, and whether it sits inside a frame.
| Property | Description | Guide |
|---|---|---|
self | This window. window.self === window is true. | Open |
name | The window’s name string. | Open |
closed | true after the window has been closed. | Open |
opener | The window that called open(), or null. | Open |
parent | The parent window; equals window on top-level pages. | Open |
top | The topmost window in the frame tree. | Open |
length | How many child frames this window contains. | Open |
frameElement | The iframe element containing this window, or null. | Open |
Size and scroll position
6 propertiesNumbers, in CSS pixels. Read them with no parentheses.
| Property | Description | Guide |
|---|---|---|
innerWidth | Viewport width in CSS pixels. | Open |
innerHeight | Viewport height in CSS pixels. | Open |
outerWidth | Full browser window width including chrome. | Open |
outerHeight | Full browser window height including chrome. | Open |
scrollX | Horizontal scroll offset in pixels. | Open |
scrollY | Vertical scroll offset in pixels. | Open |
The page this window shows
7 propertiesObjects the window keeps for the document, the URL, history, and storage.
| Property | Description | Guide |
|---|---|---|
document | The Document for this window. | Open |
location | The Location object for this window’s URL. | Open |
history | Session history for this tab. | Open |
navigator | The Navigator object (browser info). | Open |
screen | The Screen object for the display. | Open |
localStorage | Origin storage that survives tab close. | Open |
sessionStorage | Origin storage that lasts for the tab session. | Open |
Frequently Asked Questions
Call a method next
Properties are values. alert() and setTimeout() are functions.
CODETOFUN NEWS
Stay Ahead in Tech
Get the latest IT news, programming updates, and technology trends directly on your phone.
Your daily dose of tech, straight to your feed.
11 people found this page helpful
