Skip to content
Search

JavaScript:Window

lastmod 2023-11-23created 2020-10-145 edits

The Window interface represents a window containing a DOM document. The document property points to the DOM document loaded in that window. Conversely, the window for a given document can be accessed using document.defaultView.

The global variable window, exposed to JavaScript code, represents the window in which the current script is running.

The Window interface is home to a variety of functions, namespaces, objects, and constructors. Some of them are not directly related to the concept of a window as a user interface element, but are instead suited to items that need to be globally accessible. Many of these items are documented in the JavaScript reference and the DOM reference.

In a tabbed browser, each tab is represented by its own Window object. The global window object seen by JavaScript code running in a given tab always represents that tab. However, some properties and methods, such as resizeTo() and innerHeight, apply to the whole window rather than the tab. Generally, anything that cannot reasonably be tied to a tab belongs to the window.

Properties

location

// 현재 접속한 사이트 주소가: "http://localhost:20000/live/cameras" 라면:

var origin = window.location.origin;
var host = window.location.host;
var pathname = window.location.pathname;

console.debug(origin);  // "http://localhost:20000"
console.debug(host);  // "localhost:20000" 
console.debug(pathname);  // "/live/cameras"

sessionStorage

See JavaScript:Storage.

localStorage

See JavaScript:Storage.

See also

Favorite site

author Zer0 sitemap