recursal/MDN huggingface dataset:
Window: navigator property
==========================

 The **`Window.navigator`** read-only property returns a
 reference to the `Navigator` object, which has methods and properties about
 the application running the script.

Value
-----

The `navigator` object.

Examples
--------

### Example 1: Browser detect and return a string


```js
function getBrowserName(userAgent) {
  // The order matters here, and this may report false positives for unlisted browsers.

  if (userAgent.includes("Firefox")) {
    // "Mozilla/5.0 (X11; Linux i686; rv:104.0) Gecko/20100101 Firefox/104.0"
    return "Mozilla Firefox";
  } else if (userAgent.includes("SamsungBrowser")) {
    // "Mozilla/5.0 (Linux; Android 9; SAMSUNG SM-G955F Build/PPR1.180610.011) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/9.4 Chrome/67.0.3396.87 Mobile Safari/537.36"
    return "Samsung Internet";
  } else if (userAgent.includes("Opera") || userAgent.includes("OPR")) {
    // "Mozilla/5.0 (Macintosh; Intel Mac OS X 12\_5\_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36 OPR/90.0.4480.54"
    return "Opera";
  } else if (userAgent.includes("Edge")) {
    // "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299"
    return "Microsoft Edge (Legacy)";
  } else if (userAgent.includes("Edg")) {
    // "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36 Edg/104.0.1293.70"
    return "Microsoft Edge (Chromium)";
  } else if (userAgent.includes("Chrome")) {
    // "Mozilla/5.0 (X11; Linux x86\_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
    return "Google Chrome or Chromium";
  } else if (userAgent.includes("Safari")) {
    // "Mozilla/5.0 (iPhone; CPU iPhone OS 15\_6\_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6 Mobile/15E148 Safari/604.1"
    return "Apple Safari";
  } else {
    return "unknown";
  }
}

const browserName = getBrowserName(navigator.userAgent);
console.log(`You are using: ${browserName}`);
```

Specifications
--------------

| Specification |
| --- |
| HTML Standard # dom-navigator |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
Window: storage event
=====================

The **`storage`** event of the `Window` interface fires when a storage area (`localStorage` or `sessionStorage`) has been modified in the context of another document.

This event is not cancelable and does not bubble.

**Note:** This won't work on the same page that is making the changes — it is really a way for other pages on the domain using the storage to sync any changes that are made. Pages on other domains can't access the same storage objects.

Syntax
------

Use the event name in methods like `addEventListener()`, or set an event handler property.


```js
addEventListener("storage", (event) => {});
onstorage = (event) => {};
```

Event type
----------

A `StorageEvent`. Inherits from `Event`.

Event

StorageEventEvent properties
----------------

`key` Read only 

 Returns a string with the key for the storage item that was changed.
 The `key` attribute is `null` when the change is caused by the storage `clear()` method.


`newValue` Read only 

 Returns a string with the new value of the storage item that was changed.
 This value is `null` when the change has been invoked by storage `clear()` method,
 or the storage item has been removed from the storage.


`oldValue` Read only 

 Returns a string with the original value of the storage item that was changed.
 This value is `null` when the storage item has been newly added
 and therefore doesn't have any previous value.


`storageArea` Read only 

Returns a `Storage` object that represents the storage object that was affected.

`url` Read only 

Returns string with the URL of the document whose storage changed.

Event handler aliases
---------------------

In addition to the `Window` interface, the event handler property `onstorage` is also available on the following targets:

* `HTMLBodyElement`
* `HTMLFrameSetElement`
* `SVGSVGElement`
Examples
--------

Log the `sampleList` item to the console when the `storage` event fires:


```js
window.addEventListener("storage", () => {
  // When local storage changes, dump the list to
  // the console.
  console.log(JSON.parse(window.localStorage.getItem("sampleList")));
});
```


The same action can be achieved using the `onstorage` event handler property:


```js
window.onstorage = () => {
  // When local storage changes, dump the list to
  // the console.
  console.log(JSON.parse(window.localStorage.getItem("sampleList")));
};
```

Specifications
--------------

| Specification |
| --- |
| HTML Standard # event-storage |
| HTML Standard # handler-window-onstorage |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Web Storage API
* Using the Web Storage API
* Responding to storage changes with the StorageEvent
Window: sharedStorage property
==============================

**Experimental:** **This is an experimental technology**  
Check the Browser compatibility table carefully before using this in production.

The global read-only **`sharedStorage`** property returns the `WindowSharedStorage` object for the current origin. This is the main entry point for writing data to shared storage using the Shared Storage API.

**Note:** `sharedStorage` is not available inside workers. It is implemented by `Window` and is also available in shared storage worklets (see `SharedStorageWorkletGlobalScope.sharedStorage`, which returns `WorkletSharedStorage`).

Value
-----

A `WindowSharedStorage` object instance.

Examples
--------


```js
window.sharedStorage
  .set("ab-testing-group", "0")
  .then(console.log("Value saved to shared storage"));
```

Specifications
--------------

#### No specification found

No specification data found for `api.Window.sharedStorage`.  
Check for problems with this page or contribute a missing `spec_url` to mdn/browser-compat-data. Also make sure the specification is included in w3c/browser-specs.

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `WindowSharedStorage`
* Shared Storage API
Window: appinstalled event
==========================

The **`appinstalled`** event of the Web Manifest API is fired when the browser has successfully installed a page as an application.

This event is not cancelable and does not bubble.

Syntax
------

Use the event name in methods like `addEventListener()`, or set an event handler property.


```js
addEventListener("appinstalled", (event) => {});

onappinstalled = (event) => {};
```

Event type
----------

A generic `Event`.

Examples
--------

You can use the `appinstalled` event in an `addEventListener` method:


```js
window.addEventListener("appinstalled", () => {
  console.log("Thank you for installing our app!");
});
```


Or use the `onappinstalled` event handler property:


```js
window.onappinstalled = () => {
  console.log("Thank you for installing our app!");
};
```

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
Window: outerWidth property
===========================

**`Window.outerWidth`** read-only property returns the width of the outside of the browser window. It represents the width of the whole browser window including sidebar (if expanded), window chrome and window resizing borders/handles.

Notes
-----

To change the size of a window, see `window.resizeBy()` and `window.resizeTo()`.

To get the inner width of a window, i.e. the width of the page being displayed, see `window.innerWidth`.

Specifications
--------------

| Specification |
| --- |
| CSSOM View Module # dom-window-outerwidth |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `window.outerHeight`, `window.innerHeight`, `window.innerWidth`
* `window.resizeBy()`, `window.resizeTo()`
Window: devicemotion event
==========================

**Secure context:** This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The **`devicemotion`** event is fired at a regular interval and indicates the amount of physical force of acceleration the device is receiving at that time. It also provides information about the rate of rotation, if available.

This event is not cancelable and does not bubble.

Syntax
------

Use the event name in methods like `addEventListener()`, or set an event handler property.


```js
addEventListener("devicemotion", (event) => {});

ondevicemotion = (event) => {};
```

Event type
----------

A `DeviceMotionEvent`. Inherits from `Event`.

Event

DeviceMotionEventEvent properties
----------------

`DeviceMotionEvent.acceleration` Read only 

An object giving the acceleration of the device on the three axis: x, y, and z. Acceleration is expressed in m/s².

`DeviceMotionEvent.accelerationIncludingGravity` Read only 

An object giving the acceleration of the device on the three axis: x, y, and z with the effect of gravity. Acceleration is expressed in m/s².

`DeviceMotionEvent.rotationRate` Read only 

An object giving the rate of change of the device's orientation on the three orientation axis: alpha, beta and gamma. Rotation rate is expressed in degrees per seconds.

`DeviceMotionEvent.interval` Read only 

A number representing the interval of time, in milliseconds, at which data is obtained from the device.

Examples
--------


```js
function handleMotionEvent(event) {
  const x = event.accelerationIncludingGravity.x;
  const y = event.accelerationIncludingGravity.y;
  const z = event.accelerationIncludingGravity.z;

  // Do something awesome.
}

window.addEventListener("devicemotion", handleMotionEvent, true);
```

Specifications
--------------

| Specification |
| --- |
| DeviceOrientation Event Specification # devicemotion |
| DeviceOrientation Event Specification # ref-for-dom-window-ondevicemotion |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `deviceorientation`
* DeviceOrientation Event
Window: forward() method
========================

**Non-standard:** This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

 **Deprecated:** This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

Moves the window one document forward in history. This was a Firefox-specific method and was removed in Firefox 31.

**Note:** Use the standard `history.forward()` method instead.

Syntax
------


```js
forward()
```

### Parameters

None.

### Return value

None (`undefined`).

Examples
--------


```js
function goForward() {
  if (canGoForward) {
    window.forward();
  }
}
```

Specifications
--------------

This is not part of any specification.

Browser compatibility
---------------------

This non-standard method was only implemented in Firefox, and was removed in Firefox 31.

See also
--------

* `History.back()`
* `History.forward()`
Window: vrdisplayactivate event
===============================

**Deprecated:** This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

**Non-standard:** This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

The **`vrdisplayactivate`** event of the WebVR API is fired when a VR display is able to be presented to, for example if an HMD has been moved to bring it out of standby, or woken up by being put on.

**Note:** This event was part of the old WebVR API. It has been superseded by the WebXR Device API.

This event is not cancelable and does not bubble.

Syntax
------

Use the event name in methods like `addEventListener()`, or set an event handler property.


```js
addEventListener("vrdisplayactivate", (event) => {});

onvrdisplayactivate = (event) => {};
```

Event type
----------

A `VRDisplayEvent`. Inherits from `Event`.

Event properties
----------------

*`VRDisplayEvent` also inherits properties from its parent object, `Event`.*

`VRDisplayEvent.display` 
Deprecated
 Read only 

The `VRDisplay` associated with this event.

`VRDisplayEvent.reason` 
Deprecated
 Read only 

A human-readable reason why the event was fired.

Examples
--------

You can use the `vrdisplayactivate` event in an `addEventListener` method:


```js
window.addEventListener("vrdisplayactivate", () => {
  info.textContent = "Display activated.";
  reportDisplays();
});
```


Or use the `onvrdisplayactivate` event handler property:


```js
window.onvrdisplayactivate = () => {
  info.textContent = "Display activated.";
  reportDisplays();
};
```

Specifications
--------------

This event was part of the old WebVR API that has been superseded by the WebXR Device API. It is no longer on track to becoming a standard.

Until all browsers have implemented the new WebXR Device API, it is recommended to rely on frameworks, like A-Frame, Babylon.js, or Three.js, or a polyfill, to develop WebXR applications that will work across all browsers [1].

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* WebVR API
Window: screen property
=======================

 The `Window` property **`screen`** returns a
 reference to the screen object associated with the window. The `screen`
 object, implementing the `Screen` interface, is a special object for
 inspecting properties of the screen on which the current window is being rendered.

Value
-----

A `Screen` object.

Examples
--------


```js
if (screen.pixelDepth < 8) {
  // use low-color version of page
} else {
  // use regular, colorful page
}
```

Specifications
--------------

| Specification |
| --- |
| CSSOM View Module # dom-window-screen |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
Window: cut event
=================

The **`cut`** event is fired when the user has initiated a "cut" action through the browser's user interface.

The original target for this event is the `Element` that was the intended target of the cut action. You can listen for this event on the `Window` interface to handle it in the capture or bubbling phases. For full details on this event please see the page on the Element: cut event.

Syntax
------

Use the event name in methods like `addEventListener()`, or set an event handler property.


```js
addEventListener("cut", (event) => {});

oncut = (event) => {};
```

Event type
----------

A `ClipboardEvent`. Inherits from `Event`.

Event

ClipboardEventExamples
--------


```js
window.addEventListener("cut", (event) => {
  console.log("cut action initiated");
});
```

Specifications
--------------

| Specification |
| --- |
| Clipboard API and events # clipboard-event-cut |
| HTML Standard # handler-oncut |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Related events: `copy`, `paste`
* This event on `Element` targets: `cut`
* This event on `Document` targets: `cut`
Window: fullScreen property
===========================

**Non-standard:** This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

 The **`fullScreen`** property of the `Window`
 interface indicates whether the window is displayed in full screen mode or not.

Value
-----

A boolean value with `true` meaning that the window is in full-screen mode and `false` meaning it isn't.

Notes
-----

* Switching between regular window and full screen will fire the "resize" event on the
 corresponding window.
Examples
--------


```js
if (window.fullScreen) {
  // it's fullscreen!
} else {
  // not fullscreen!
}
```

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
Window: cancelAnimationFrame() method
=====================================

 The **`window.cancelAnimationFrame()`** method cancels an
 animation frame request previously scheduled through a call to
 `window.requestAnimationFrame()`.

Syntax
------


```js
cancelAnimationFrame(requestID)
```

### Parameters

`requestID`

 The ID value returned by the call to `window.requestAnimationFrame()`
 that requested the callback.


### Return value

None (`undefined`).

Examples
--------


```js
const requestAnimationFrame =
  window.requestAnimationFrame ||
  window.mozRequestAnimationFrame ||
  window.webkitRequestAnimationFrame ||
  window.msRequestAnimationFrame;

const cancelAnimationFrame =
  window.cancelAnimationFrame || window.mozCancelAnimationFrame;

const start = Date.now();

let myReq;

function step(timestamp) {
  const progress = timestamp - start;
  d.style.left = `${Math.min(progress / 10, 200)}px`;
  if (progress < 2000) {
    // it's important to update the requestId each time you're calling requestAnimationFrame
    myReq = requestAnimationFrame(step);
  }
}
myReq = requestAnimationFrame(step);
// the cancellation uses the last requestId
cancelAnimationFrame(myReq);
```

Specifications
--------------

| Specification |
| --- |
| HTML Standard # animationframeprovider-cancelanimationframe |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `Window.requestAnimationFrame()`
* `DedicatedWorkerGlobalScope.cancelAnimationFrame()`
Window: vrdisplaydisconnect event
=================================

**Deprecated:** This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

**Non-standard:** This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

The **`vrdisplaydisconnect`** event of the WebVR API is fired when a compatible VR display is disconnected from the computer.

This event is not cancelable and does not bubble.

Syntax
------

Use the event name in methods like `addEventListener()`, or set an event handler property.


```js
addEventListener("vrdisplaydisconnect", (event) => {});

onvrdisplaydisconnect = (event) => {};
```

Event type
----------

A `VRDisplayEvent`. Inherits from `Event`.

Event properties
----------------

*`VRDisplayEvent` also inherits properties from its parent object, `Event`.*

`VRDisplayEvent.display` 
Deprecated
 Read only 

The `VRDisplay` associated with this event.

`VRDisplayEvent.reason` 
Deprecated
 Read only 

A human-readable reason why the event was fired.

Examples
--------

You can use the `vrdisplaydisconnect` event in an `addEventListener` method:

**Note:** This event was part of the old WebVR API. It has been superseded by the WebXR Device API.


```js
window.addEventListener("vrdisplaydisconnect", () => {
  info.textContent = "Display disconnected.";
  reportDisplays();
});
```


Or use the `onvrdisplaydisconnect` event handler property:


```js
window.onvrdisplaydisconnect = () => {
  info.textContent = "Display disconnected.";
  reportDisplays();
};
```

Specifications
--------------

This event was part of the old WebVR API that has been superseded by the WebXR Device API. It is no longer on track to becoming a standard.

Until all browsers have implemented the new WebXR Device API, it is recommended to rely on frameworks, like A-Frame, Babylon.js, or Three.js, or a polyfill, to develop WebXR applications that will work across all browsers [1].

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* WebVR API
Window: online event
====================

The **`online`** event of the `Window` interface is fired when the browser has gained access to the network and the value of `Navigator.onLine` switches to `true`.

**Note:** This event shouldn't be used to determine the availability of a particular website. Network problems or firewalls might still prevent the website from being reached.

Syntax
------

Use the event name in methods like `addEventListener()`, or set an event handler property.


```js
addEventListener("online", (event) => {});
ononline = (event) => {};
```

Event type
----------

A generic `Event`.

Event handler aliases
---------------------

In addition to the `Window` interface, the event handler property `ononline` is also available on the following targets:

* `HTMLBodyElement`
* `HTMLFrameSetElement`
* `SVGSVGElement`
Examples
--------


```js
// addEventListener version
window.addEventListener("online", (event) => {
  console.log("You are now connected to the network.");
});

// ononline version
window.ononline = (event) => {
  console.log("You are now connected to the network.");
};
```

Specifications
--------------

| Specification |
| --- |
| HTML Standard # event-online |
| HTML Standard # handler-window-ononline |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `offline`