Javascript Window - 103 Events (Reference)

Tech:
Javascript
Since:
1 year ago
Views:
4

Window Object in Javascript is a global object that is available in all web pages. This window object methods to access/modify the global information.

orientationchange

The orientationchange event is fired when the orientation of the device has changed.

window.addEventListener("orientationchange", function(e) {});
window.onorientationchange = function(e) {};

devicemotion

The devicemotion event is fired when the device has been moved by the user. That is if the accelerometer detects a change this event will fire. Mostly used for mobile devices.

window.addEventListener("devicemotion", function(e) {});
window.ondevicemotion = function(e) {};

deviceorientation

The deviceorientation event is fired when the device has been rotated by the user. That is if the magnetometer detects a change this event will fire. Mostly used for mobile devices.

window.addEventListener("deviceorientation", function(e) {});
window.ondeviceorientation = function(e) {};

gamepadconnected

The gamepadconnected event is fired when a gamepad has been connected.

window.addEventListener("gamepadconnected", function(e) {});
window.ongamepadconnected = function(e) {};

gamepaddisconnected

The gamepaddisconnected event is fired when a gamepad has been disconnected.

window.addEventListener("gamepaddisconnected", function(e) {});
window.ongamepaddisconnected = function(e) {};

rejectionhandled

The rejectionhandled event is fired when a promise has been rejected.

window.addEventListener("rejectionhandled", function(e) {});
window.onrejectionhandled = function(e) {};

unhandledrejection

The unhandledrejection event is fired when a promise has been rejected and there is no handler.

window.addEventListener("unhandledrejection", function(e) {});
window.onunhandledrejection = function(e) {};

languagechange

The languagechange event is fired when the language of the browser has changed.

window.addEventListener("languagechange", function(e) {});
window.onlanguagechange = function(e) {};

resize

The resize event is fired when the browser window has been resized.

window.addEventListener("resize", function(e) {});
window.onresize = function(e) {};

storage

The storage event is fired when a storage area (localStorage or sessionStorage) has been modified.

window.addEventListener("storage", function(e) {});
window.onstorage = function(e) {};

offline

The offline event is fired when the browser is offline.

window.addEventListener("offline", function(e) {});
window.onoffline = function(e) {};

online

The online event is fired when the browser is online.

window.addEventListener("online", function(e) {});
window.ononline = function(e) {};

pagehide

The pagehide event is fired when the page is hidden.

window.addEventListener("pagehide", function(e) {});
window.onpagehide = function(e) {};

pageshow

The pageshow event is fired when the page is shown.

window.addEventListener("pageshow", function(e) {});
window.onpageshow = function(e) {};

hashchange

The hashchange event is fired when the fragment identifier of the URL has changed.

window.addEventListener("hashchange", function(e) {});
window.onhashchange = function(e) {};

popstate

The popstate event is fired when the session history state has changed.

window.addEventListener("popstate", function(e) {});
window.onpopstate = function(e) {};

beforeunload

The beforeunload event is fired when the window is about to be unloaded.

window.addEventListener("beforeunload", function(e) {});
window.onbeforeunload = function(e) {};

DOMContentLoaded

The DOMContentLoaded event is fired when the document has been completely loaded and parsed, without waiting for stylesheets, images, and subframes to finish loading.

window.addEventListener("DOMContentLoaded", function(e) {});
window.onDOMContentLoaded = function(e) {};

load

The load event is fired when the document has finished loading (but the load event may not have been sent).

window.addEventListener("load", function(e) {});
window.onload = function(e) {};

unload

The unload event is fired when the document has been removed from a window or frame.

window.addEventListener("unload", function(e) {});
window.onunload = function(e) {};

afterprint

The afterprint event is fired when the document has been printed.

window.addEventListener("afterprint", function(e) {});
window.onafterprint = function(e) {};

beforeprint

The beforeprint event is fired when the document is about to be printed.

window.addEventListener("beforeprint", function(e) {});
window.onbeforeprint = function(e) {};

Common events

Document Events which also available in Window and Element are listed here.