recursal/MDN huggingface dataset:
Window: paste event
===================

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

The original target for this event is the `Element` that was the intended target of the paste 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: paste event.

Syntax
------

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


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

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

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

A `ClipboardEvent`. Inherits from `Event`.

Event

ClipboardEventExamples
--------


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

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

| Specification |
| --- |
| Clipboard API and events # clipboard-event-paste |
| HTML Standard # handler-onpaste |

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

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

See also
--------

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

 The **`Window.frameElement`** property
 returns the element (such as `<iframe>` or `<object>`)
 in which the window is embedded.


**Note:** Despite this property's name, it works for documents embedded
 within any embedding point, including `<object>`,
 `<iframe>`, or `<embed>`.


Value
-----

 The element which the window is embedded into. If the window isn't embedded into
 another document, or if the document into which it's embedded has a different
 origin, the value is `null` instead.

Examples
--------


```js
const frameEl = window.frameElement;
// If we're embedded, change the containing element's URL to 'https://mozilla.org/'
if (frameEl) {
  frameEl.src = "https://mozilla.org/";
}
```

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

| Specification |
| --- |
| HTML Standard # dom-frameelement-dev |

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

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

See also
--------

* `window.frames` returns an array-like object, listing the direct
 sub-frames of the current window.
* `window.parent` returns the parent window, which is the window
 containing the `frameElement` of the child window.
Window: screenTop property
==========================

 The **`Window.screenTop`** read-only property returns the
 vertical distance, in CSS pixels, from the top border of the user's browser viewport to
 the top side of the screen.


**Note:** `screenTop` is an alias of the older
 `Window.screenY` property. `screenTop` was originally
 supported only in IE but was introduced everywhere due to popularity.


Value
-----

 A number equal to the number of CSS pixels from the top edge of the browser viewport to
 the top edge of the screen.

Examples
--------

 In our screenleft-screentop
 example, you'll see a canvas onto which has been drawn a circle. In this example we are
 using `screenLeft`/`screenTop` plus
 `Window.requestAnimationFrame()` to constantly redraw the circle in the
 same physical position on the screen, even if the window position is moved.


```js
initialLeft = window.screenLeft + canvasElem.offsetLeft;
initialTop = window.screenTop + canvasElem.offsetTop;

function positionElem() {
  let newLeft = window.screenLeft + canvasElem.offsetLeft;
  let newTop = window.screenTop + canvasElem.offsetTop;

  let leftUpdate = initialLeft - newLeft;
  let topUpdate = initialTop - newTop;

  ctx.fillStyle = "rgb(0 0 0)";
  ctx.fillRect(0, 0, width, height);
  ctx.fillStyle = "rgb(0 0 255)";
  ctx.beginPath();
  ctx.arc(
    leftUpdate + width / 2,
    topUpdate + height / 2 + 35,
    50,
    degToRad(0),
    degToRad(360),
    false,
  );
  ctx.fill();

  pElem.textContent = `Window.screenLeft: ${window.screenLeft}, Window.screenTop: ${window.screenTop}`;

  window.requestAnimationFrame(positionElem);
}

window.requestAnimationFrame(positionElem);
```


 Also in the code we include a snippet that detects whether `screenLeft` is
 supported, and if not, polyfills in `screenLeft`/`screenTop` using
 `Window.screenX`/`Window.screenY`.


```js
if (!window.screenLeft) {
  window.screenLeft = window.screenX;
  window.screenTop = window.screenY;
}
```

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

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

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

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

See also
--------

* `window.screenLeft`
* `Window.screenY`
Window: setResizable() method
=============================

**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.

This method does nothing; it is a no-op. It is solely kept for compatibility with Netscape 4.x.

Syntax
------


```js
setResizable()
```

### Return value

None (`undefined`).

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

Not part of any current specifications.

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

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

The `Window.history` read-only property returns a reference to the `History` object, which provides an interface for manipulating the browser *session history* (pages visited in the tab or frame that the current page is loaded in).

See Manipulating the browser history for examples and details. In particular, that article explains security features of the `pushState()` and `replaceState()` methods that you should be aware of before using them.

Value
-----

A reference to the `History` object.

Examples
--------


```js
history.back(); // equivalent to clicking back button
history.go(-1); // equivalent to history.back();
```

Notes
-----

For top-level pages you can see the list of pages in the session history, accessible via the `History` object, in the browser's dropdowns next to the back and forward buttons.

For security reasons the `History` object doesn't allow the non-privileged code to access the URLs of other pages in the session history, but it does allow it to navigate the session history.

There is no way to clear the session history or to disable the back/forward navigation from unprivileged code. The closest available solution is the `location.replace()` method, which replaces the current item of the session history with the provided URL.

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

| Specification |
| --- |
| HTML Standard # the-history-interface |

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

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
Window: scrollByLines() 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.

 The **`Window.scrollByLines()`** method scrolls the document by
 the specified number of lines.

Syntax
------


```js
scrollByLines(lines)
```

### Parameters

* `lines` is the number of lines to scroll the document by. It may be a
 positive or negative integer.
### Return value

None (`undefined`).

Examples
--------


```html
<!-- Scroll up the document by 5 lines -->
<button id="scroll-up" onclick="scrollByLines(-5);">Up 5 lines</button>

<!-- Scroll down the document by 5 lines -->
<button id="scroll-down" onclick="scrollByLines(5);">Down 5 lines</button>
```

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

This is not part of any specification.

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

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

See also
--------

* `window.scroll()`
* `window.scrollBy()`
* `window.scrollByPages()`
* `window.scrollTo()`
Window: copy event
==================

The **`copy`** event fires when the user initiates a copy action through the browser's user interface.

The original target for this event is the `Element` that was the intended target of the copy 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: copy event.

Syntax
------

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


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

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

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

A `ClipboardEvent`. Inherits from `Event`.

Event

ClipboardEventExamples
--------


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

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

| Specification |
| --- |
| Clipboard API and events # clipboard-event-copy |
| HTML Standard # handler-oncopy |

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

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

See also
--------

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

The **`offline`** event of the `Window` interface is fired when the browser has lost access to the network and the value of `Navigator.onLine` switches to `false`.

Syntax
------

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


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

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

A generic `Event`.

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

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

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


```js
// addEventListener version
window.addEventListener("offline", (event) => {
  console.log("The network connection has been lost.");
});

// onoffline version
window.onoffline = (event) => {
  console.log("The network connection has been lost.");
};
```

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

| Specification |
| --- |
| HTML Standard # event-offline |
| HTML Standard # handler-window-onoffline |

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

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

See also
--------

* `online`
Window: external property
=========================

**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.

The `external` property of the `Window` API returns an instance of the `External` interface, which was intended to contain functions related to adding external search providers to the browser. However, this is now deprecated, and the contained methods are now dummy functions that do nothing as per spec.

Instance methods
----------------

The `External` object has the following methods:

| Method | Description |
| --- | --- |
| `AddSearchProvider(*descriptionURL)*` | 
 Dummy function; does nothing. See
 Autodiscovery of search plugins.
  |
| `IsSearchProviderInstalled()` | Dummy function; does nothing. |

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

| Specification |
| --- |
| HTML Standard # external |

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

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

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

The `launchQueue` read-only property of the `Window` interface provides access to the `LaunchQueue` class, which allows custom launch navigation handling to be implemented in a progressive web app (PWA), with the handling context signified by the `launch_handler` manifest field `client_mode` value.

The custom launch navigation handling functionality is controlled by the properties of the `LaunchParams` object passed into the `LaunchQueue.setConsumer()` callback function.

Value
-----

A `LaunchQueue` object instance.

Examples
--------


```js
if ("launchQueue" in window) {
  window.launchQueue.setConsumer((launchParams) => {
    if (launchParams.targetURL) {
      const params = new URL(launchParams.targetURL).searchParams;

      // Assuming a music player app that gets a track passed to it to be played
      const track = params.get("track");
      if (track) {
        audio.src = track;
        title.textContent = new URL(track).pathname.substring(1);
        audio.play();
      }
    }
  });
}
```

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

| Specification |
| --- |
| Web App Launch Handler API # launchqueue-interface |

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

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

See also
--------

* Launch Handler API
* Launch Handler API: Control how your app is launched
* `Window.launchQueue`
* Musicr 2.0 demo app
Window: gamepaddisconnected event
=================================

The `gamepaddisconnected` event is fired when the browser detects that a gamepad has been disconnected.

The event will not fire if disallowed by the document's `gamepad` Permissions Policy.

This event is not cancelable and does not bubble.

Examples
--------

To be informed when a gamepad is disconnected, you can add a handler to the window using `addEventListener()`, like this:


```js
window.addEventListener("gamepaddisconnected", (event) => {
  console.log("Lost connection with the gamepad.");
});
```


Alternatively, you can use the `window.ongamepaddisconnected` event handler property to establish a handler for the `gamepaddisconnected` event:


```js
window.ongamepaddisconnected = (event) => {
  console.log("Lost connection with the gamepad.");
};
```

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

| Specification |
| --- |
| Gamepad # event-gamepaddisconnected |

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

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

See also
--------

* gamepadconnected
* Using Gamepad API
Window: deviceorientation event
===============================

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

The **`deviceorientation`** event is fired when fresh data is available from an orientation sensor about the current orientation of the device as compared to the Earth coordinate frame. This data is gathered from a magnetometer inside the device.

See Orientation and motion data explained for details.

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("deviceorientation", (event) => {});

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

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

A `DeviceOrientationEvent`. Inherits from `Event`.

Event

DeviceOrientationEventEvent properties
----------------

`DeviceOrientationEvent.absolute` Read only 

A boolean that indicates whether the device is providing orientation data absolutely.

`DeviceOrientationEvent.alpha` Read only 

A number representing the motion of the device around the z axis, express in degrees with values ranging from 0 (inclusive) to 360 (exclusive).

`DeviceOrientationEvent.beta` Read only 

A number representing the motion of the device around the x axis, expressed in degrees with values ranging from -180 (inclusive) to 180 (exclusive). This represents the front to back motion of the device.

`DeviceOrientationEvent.gamma` Read only 

A number representing the motion of the device around the y axis, expressed in degrees with values ranging from -90 (inclusive) to 90 (exclusive). This represents the left to right motion of the device.

`DeviceOrientationEvent.webkitCompassHeading` 
Non-standard
 Read only 

A number represents the difference between the motion of the device around the z axis of the world system and the direction of the north, expressed in degrees with values ranging from 0 to 360.

`DeviceOrientationEvent.webkitCompassAccuracy` 
Non-standard
 Read only 

The accuracy of the compass given as a positive or negative deviation. It's usually 10.

Examples
--------


```js
if (window.DeviceOrientationEvent) {
  window.addEventListener(
    "deviceorientation",
    (event) => {
      const rotateDegrees = event.alpha; // alpha: rotation around z-axis
      const leftToRight = event.gamma; // gamma: left to right
      const frontToBack = event.beta; // beta: front back motion

      handleOrientationEvent(frontToBack, leftToRight, rotateDegrees);
    },
    true,
  );
}

const handleOrientationEvent = (frontToBack, leftToRight, rotateDegrees) => {
  // do something amazing
};
```

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

| Specification |
| --- |
| DeviceOrientation Event Specification # deviceorientation |
| DeviceOrientation Event Specification # ref-for-dom-window-ondeviceorientation |

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

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

See also
--------

* `devicemotion`
* Detecting device orientation
* Orientation and motion data explained
Window: vrdisplaypresentchange 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 **`vrdisplaypresentchange`** event of the WebVR API is fired when the presenting state of a VR display changes — i.e. goes from presenting to not presenting, or vice versa.

**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("vrdisplaypresentchange", (event) => {});

onvrdisplaypresentchange = (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 `vrdisplaypresentchange` event in an `addEventListener` method:


```js
window.addEventListener("vrdisplaypresentchange", () => {
  info.textContent = vrDisplay.isPresenting
    ? "Display has started presenting."
    : "Display has stopped presenting.";
  reportDisplays();
});
```


Or use the `onvrdisplaypresentchange` event handler property:


```js
window.onvrdisplaypresentchange = () => {
  info.textContent = vrDisplay.isPresenting
    ? "Display has started presenting."
    : "Display has stopped presenting.";
  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: confirm() method
========================

`window.confirm()` instructs the browser to display a dialog with an optional message, and to wait until the user either confirms or cancels the dialog.

Under some conditions — for example, when the user switches tabs — the browser may not actually display a dialog, or may not wait for the user to confirm or cancel the dialog.

Syntax
------


```js
confirm(message)
```

### Parameters

`message`

A string you want to display in the confirmation dialog.

### Return value

 A boolean indicating whether OK (`true`) or Cancel (`false`) was
 selected. If a browser is ignoring in-page dialogs, then the returned value is always
 `false`.

Examples
--------


```js
if (window.confirm("Do you really want to leave?")) {
  window.open("exit.html", "Thanks for Visiting!");
}
```


Produces:

![Firefox confirm](/en-US/docs/Web/API/Window/confirm/firefox_confirm_dialog.png)

Notes
-----

 Dialog boxes are modal windows — they
 prevent the user from accessing the rest of the program's interface until the dialog box
 is closed. For this reason, you should not overuse any function that creates a dialog
 box (or modal window). Regardless, there are good reasons to avoid using dialog boxes for confirmation.

Alternatively `<dialog>` element can be used for confirmations.

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

| Specification |
| --- |
| HTML Standard # dom-confirm-dev |

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

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

See also
--------

* `<dialog>` element
* `window.alert()`
* `window.prompt()`