Quick Reference
This is a quick reference list of JavaScript window methods and properties with examples of how they are used.
- JavaScript – Window alert() MethodThe Window alert() method displays an alert popup in the browser with a message and OK button, and is used to display information to the user.
- JavaScript – window.atob() MethodThe window.atob() method decodes a base-64 encoded string.
- JavaScript – Window blur() MethodThe Window blur() method removes focus from a window.
- JavaScript – window.btoa() MethodThe window.btoa() method encodes a string in base-64.
- JavaScript – Window clearInterval() MethodThe Window clearInterval() method clears a timer set with the setInterval() method.
- JavaScript – Window clearTimeout() MethodThe Window clearTimeout() method clears a timer set with the setTimeout() method.
- JavaScript – Window close() MethodThe Window close() method closes a browser window (or tab depending on how the user has their browser set up).
- JavaScript – Window closed PropertyThe Window closed property returns “true” if the specified window is closed.
- JavaScript – Window confirm() MethodThe Window confirm() method displays a dialog box with a message, an OK button, and Cancel button.
- JavaScript – Window focus() MethodThe Window focus() method sets focus to a window.
- JavaScript – window.frameElement PropertyThe window.frameElement property returns the frame where the window runs, or null if the window does not run in a frame.
- JavaScript – window.getComputedStyle() MethodThe window.getComputedStyle() method gets the computed CSS properties and values of an HTML element.
- JavaScript – window.frames PropertyThe window.frames property returns an array with all window objects in the window.
- JavaScript – window.innerHeight PropertyThe window.innerHeight property returns the height of a window’s content area.
- JavaScript – window.innerWidth PropertyThe window.innerWidth property returns the width of a window’s content area.
- JavaScript – window.length PropertyThe window.length property returns the number of (framed) windows in the window. The count starts with 0 for the 1st, 1 for the 2nd, etc.
- JavaScript – window.localStorage PropertyThe window.localStorage object allows you to save key/value pairs in the browser.
- JavaScript – window.matchMedia() MethodThe window.matchMedia() method returns a MediaQueryList with the results from the query.
- JavaScript – Window moveBy() MethodThe Window moveBy() method moves a window a number of pixels, both horizontal and vertical, relative to its current coordinates.
- JavaScript – Window moveTo() MethodThe Window moveTo() method moves a window to a new horizontal and vertical position.
- JavaScript – Window name PropertyThe Window name property sets or returns the name of the window.
- JavaScript – window.open() MethodThe window.open() method opens a new browser window/tab, depending on the browser settings and the parameter values.
- JavaScript – Window opener PropertyThe opener property returns a reference to the window that created the window.
- JavaScript – window.outerHeight PropertyThe window.outerHeight property returns the outer height of the browser window, including all interface elements such as toolbars and scrollbars.
- JavaScript – window.outerWidth PropertyThe window.outerWidth property returns the outer width of the browser window, including all interface elements such as toolbars and scrollbars.
- JavaScript – window.pageXOffset PropertyThe window.pageXOffset property returns the pixels a document has scrolled the page right from the upper left corner of the window.
- JavaScript – window.pageYOffset PropertyThe window.pageYOffset property returns the pixels a document has scrolled down the page from the upper left corner of the window.
- JavaScript – window.parent PropertyThe window.parent property returns the parent window of the current window.
- JavaScript – window.print() MethodThe window.print() method opens a print dialog box, which lets the user select from printing options to print the contents of the window.
- JavaScript – Window prompt() MethodThe Window prompt() method displays a dialog box that prompts the user for input.
- JavaScript – Window resizeBy() MethodThe Window resizeBy() method resizes a window by a specified amount.
- JavaScript – Window resizeTo() MethodThe Window resizeTo() method resizes a window to a specified width and height.
- JavaScript – window.screenLeft PropertyThe window.screenLeft property returns the horizontal position of a window, relative to the screen.
- JavaScript – window.screenTop PropertyThe window.screenTop property returns the vertical position of a window, relative to the screen.
- JavaScript – Window screenX PropertyThe Window screenX property returns the horizontal coordinate of a window, relative to the screen.
- JavaScript – Window screenY PropertyThe Window screenY property returns the vertical coordinate of a window, relative to the screen.
- JavaScript – window.scrollBy() MethodThe window.scrollBy() method scrolls the document by the specified number of pixels, but only if the page is longer than the window.
- JavaScript – window.scrollTo() MethodThe window.scrollTo() method scrolls the document to specified coordinates.
- JavaScript – window.scrollX PropertyThe window.scrollX property returns the pixels a document has scrolled horizontally from the upper left corner of the window.
- JavaScript – window.scrollY PropertyThe window.scrollY property returns the pixels a document has scrolled vertically from the upper left corner of the window.
- JavaScript – window.self PropertyThe window.self property returns the current window.
- JavaScript – Window sessionStorage PropertyThe Window sessionStorage object lets you store key/value pairs in the browser.
- JavaScript – Window setInterval() MethodThe Window setInterval() method calls a function at specified intervals (in milliseconds).
- JavaScript – Window setTimeout() MethodThe Window setTimeout() method calls a function after a number of milliseconds.
- JavaScript – window.stop() MethodThe window.stop() method stops a window from loading, and is the same as clicking stop in the browser.
- JavaScript – window.top PropertyThe window.top property returns the topmost window in the current browser window.
JavaScript Notes:
- When using JavaScript, single or double quotation marks are acceptable and work identically to one another; choose whichever you prefer, and stay consistent
- JavaScript is a case-sensitive language; firstName is NOT the same as firstname
- Arrays count starting from zero NOT one; so item 1 is position [0], item 2 is position [1], and item 3 is position [2] … and so on
- JavaScript variables must begin with a letter, $, or _
- JavaScript variables are case sensitive (x is not the same as X)
We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.