recursal/MDN huggingface dataset:
Window: scrollMaxX 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 **`Window.scrollMaxX`** read-only property returns the
 maximum number of pixels that the document can be scrolled horizontally.

Value
-----

A number.

Examples
--------


```js
// Scroll to right edge of the page
let maxX = window.scrollMaxX;

window.scrollTo(maxX, 0);
```

Notes
-----

 Do not use this property to get the total document width, which is not equivalent to window.innerWidth + window.scrollMaxX,
 because `window.innerWidth` includes the width of any visible vertical
 scrollbar, thus the result would exceed the total document width by the width of any
 visible vertical scrollbar. Instead use
 `document.body.scrollWidth`. See also
 `window.scrollMaxY`.

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.
Window: scroll() method
=======================

 The **`Window.scroll()`** method scrolls the window to a
 particular place in the document.

Syntax
------


```js
scroll(x-coord, y-coord)
scroll(options)
```

### Parameters

* `x-coord` is the pixel along the horizontal axis of the document that you
 want displayed in the upper left.
* `y-coord` is the pixel along the vertical axis of the document that you
 want displayed in the upper left.

- or -

`options`

A dictionary containing the following parameters:

`top`

Specifies the number of pixels along the Y axis to scroll the window or element.

`left`

Specifies the number of pixels along the X axis to scroll the window or element.

`behavior`

Determines whether scrolling is instant or animates smoothly. This option is a string which must take one of the following values:

* `smooth`: scrolling should animate smoothly
* `instant`: scrolling should happen instantly in a single jump
* `auto`: scroll behavior is determined by the computed value of `scroll-behavior`


### Return value

None (`undefined`).

Examples
--------


```html
<!-- put the 100th vertical pixel at the top of the window -->

<button onclick="scroll(0, 100);">click to scroll to the 100th pixel</button>
```


Using `options`:


```js
window.scroll({
  top: 100,
  left: 100,
  behavior: "smooth",
});
```

Notes
-----

`Window.scrollTo()` is effectively the same as this method. For relative
 scrolling, see `Window.scrollBy()`, `Window.scrollByLines()`,
 and `Window.scrollByPages()`.

 For scrolling elements, see `Element.scrollTop` and
 `Element.scrollLeft`.

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

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

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

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

See also
--------

* `Window.scrollByLines()`
* `Window.scrollByPages()`
* `Element.scrollIntoView()`
Window: sidebar 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.

**Warning:** This non-standard Firefox-only alias of the `window.external` property has been removed.

Returns a sidebar object which contains several methods for registering add-ons with the browser.

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

The sidebar object returned has the following methods:

| Method | Description (SeaMonkey) | Description (Firefox) |
| --- | --- | --- |
| `addPanel(title, contentURL, "")` | Adds a sidebar panel. | 
 Obsolete since Firefox 23 (only present in SeaMonkey).End users
 can use the "load this bookmark in the sidebar" option instead. Also see
 Creating a Firefox sidebar. |
| `addPersistentPanel(title, contentURL, "")` | Adds a sidebar panel, which is able to work in the background. |
| `AddSearchProvider(*descriptionURL)*` | 
 Dummy function; does nothing. See
 Autodiscovery of search plugins.
  |
| `addSearchEngine(engineURL, iconURL,
suggestedTitle, suggestedCategory)`

Deprecated
 | 
 Installs a search engine (Sherlock).
 Adding Sherlock search engines contains more details.


**Note:** This was made obsolete in Firefox 44, and has
 been removed completely in Firefox 59.

 |
| `IsSearchProviderInstalled(*descriptionURL)*` | Indicates if a specific search provider (OpenSearch) is installed. |

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

Mozilla-specific. Not part of any standard.

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

 Removed in Firefox 102.
 For more information see Firefox compatibility information in `window.external`.
Window: closed property
=======================

 The **`Window.closed`** read-only property indicates whether
 the referenced window is closed or not.

Value
-----

A boolean value. Possible values:

* `true`: The window has been closed.
* `false`: The window is open.
Examples
--------

### Change the URL of a window from a popup

 The following example demonstrates how a popup window can change the URL of the window
 that opened it. Before attempting to change the URL, it checks that the current window
 has an opener using the `window.opener` property and that the opener isn't
 closed:


```js
// Check that an opener exists and is not closed
if (window.opener && !window.opener.closed) {
  window.opener.location.href = "http://www.mozilla.org";
}
```


Note that popups can only access the window that opened them.

### Refreshing a previously opened popup

 In this example the function `refreshPopupWindow()` calls the
 `reload()` method of the popup's location object to refresh its data. If the
 popup hasn't been opened yet or the user has closed it a new window is opened.


```js
let popupWindow = null;

function refreshPopupWindow() {
  if (popupWindow && !popupWindow.closed) {
    // popupWindow is open, refresh it
    popupWindow.location.reload(true);
  } else {
    // Open a new popup window
    popupWindow = window.open("popup.html", "dataWindow");
  }
}
```

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

| Specification |
| --- |
| HTML Standard # dom-window-closed-dev |

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

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

Returns the `personalbar` object.

This is one of a group of `Window` properties that contain a boolean `visible` property, that used to represent whether or not a particular part of a web browser's user interface was visible.

For privacy and interoperability reasons, the value of the `visible` property is now `false` if this `Window` is a popup, and `true` otherwise.

Value
-----

An object containing a single property:

`visible` Read only 

A boolean property, `false` if this `Window` is a popup, and `true` otherwise.

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

| Specification |
| --- |
| HTML Standard # dom-window-personalbar-dev |

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

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

See also
--------

* `window.locationbar`
* `window.menubar`
* `window.scrollbars`
* `window.statusbar`
* `window.toolbar`
Window: event 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 read-only `Window` property **`event`** returns the `Event` which is currently being handled by the site's code. Outside the context of an event handler, the value is always `undefined`.

You *should* avoid using this property in new code, and should instead use the `Event` passed into the event handler function. This property is not universally supported and even when supported introduces potential fragility to your code.

**Note:** This property can be fragile, in that there may be situations in which the returned `Event` is not the expected value. In addition, `Window.event` is not accurate for events dispatched within shadow trees.

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

| Specification |
| --- |
| DOM Standard # dom-window-event |

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

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

See also
--------

* `Event.srcElement`
Window: cancelIdleCallback() method
===================================

 The **`window.cancelIdleCallback()`** method cancels a callback
 previously scheduled with `window.requestIdleCallback()`.

Syntax
------


```js
cancelIdleCallback(handle)
```

### Parameters

`handle`

 The ID value returned by `window.requestIdleCallback()` when the
 callback was established.


### Return value

None (`undefined`).

Examples
--------

 See our complete example
 in the article Cooperative Scheduling of Background Tasks API.

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

| Specification |
| --- |
| requestIdleCallback() Cooperative Scheduling of Background Tasks # the-cancelidlecallback-method |

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

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
Window: vrdisplaydeactivate 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 **`vrdisplaydeactivate`** event of the WebVR API is fired when a VR display can no longer be presented to, for example if an HMD has gone into standby or sleep mode due to a period of inactivity.

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

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


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


Or use the `onvrdisplaydeactivate` event handler property:


```js
window.onvrdisplaydeactivate = () => {
  info.textContent = "Display deactivated.";
  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: mozInnerScreenX 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.

 Gets the X coordinate of the top-left corner of the window's viewport, in screen
 coordinates.

**Note:** This coordinate is reported in CSS pixels, not in hardware pixels. That means it can be affected by the zoom level; to compute the actual number of physical screen pixels, you should use the `nsIDOMWindowUtils.screenPixelsPerCSSPixel` property.

Value
-----

The `window.mozInnerScreenX` property is a floating point, read-only value; it has no default value.

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

 Not part of any W3C technical
 specification or recommendation.

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

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

See also
--------

* `window.mozInnerScreenY`
* `nsIDOMWindowUtils.screenPixelsPerCSSPixel`
Window: rejectionhandled event
==============================

The **`rejectionhandled`** event is sent to the script's global scope (usually `window` but also `Worker`) whenever a rejected JavaScript `Promise` is handled late, i.e. when a handler is attached to the promise after its rejection had caused an `unhandledrejection` event.

This can be used in debugging and for general application resiliency, in tandem with the `unhandledrejection` event, which is sent when a promise is rejected but there is no handler for the rejection at the time.

Syntax
------

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


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

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

A `PromiseRejectionEvent`. Inherits from `Event`.

Event

PromiseRejectionEventEvent properties
----------------

`PromiseRejectionEvent.promise` Read only 

The JavaScript `Promise` that was rejected.

`PromiseRejectionEvent.reason` Read only 

A value or `Object` indicating why the promise was rejected, as passed to `Promise.reject()`.

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

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

* `HTMLBodyElement`
* `HTMLFrameSetElement`
* `SVGSVGElement`
Example
-------

You can use the `rejectionhandled` event to log promises that get rejected to the console, along with the reasons why they were rejected:


```js
window.addEventListener(
  "rejectionhandled",
  (event) => {
    console.log(`Promise rejected; reason: ${event.reason}`);
  },
  false,
);
```

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

| Specification |
| --- |
| HTML Standard # unhandled-promise-rejections |
| HTML Standard # handler-window-onrejectionhandled |

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

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

See also
--------

* Promise rejection events
* `PromiseRejectionEvent`
* `Promise`
* `unhandledrejection`
Window: pageshow event
======================

The **`pageshow`** event is sent to a `Window` when the browser displays the window's document due to navigation.

This includes:

* Initially loading the page
* Navigating to the page from another page in the same window or tab
* Restoring a frozen page on mobile OSes
* Returning to the page using the browser's forward or back buttons

**Note:** During the initial page load, the `pageshow` event fires *after* the `load` event.

Syntax
------

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


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

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

A `PageTransitionEvent`. Inherits from `Event`.

Event

PageTransitionEventEvent properties
----------------

`PageTransitionEvent.persisted` Read only 

Indicates if the document is loading from a cache.

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

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

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

This example sets up event handlers for events listed in the array `events`. The handler, `eventLogger()`, logs the type of event that occurred to the console, and includes the value of the `persisted` flag on `pageshow` and `pagehide` events.

### JavaScript


```js
const events = ["pagehide", "pageshow", "unload", "load"];

const eventLogger = (event) => {
  switch (event.type) {
    case "pagehide":
    case "pageshow": {
      let isPersisted = event.persisted ? "persisted" : "not persisted";
      console.log(`Event: ${event.type} - ${isPersisted}`);
      break;
    }
    default:
      console.log(`Event: ${event.type}`);
      break;
  }
};

events.forEach((eventName) => window.addEventListener(eventName, eventLogger));
```

### HTML


```html
<p>
  Open the console and watch the output as you navigate to and from this page.
  Try loading new pages into this tab, then navigating forward and backward
  through history, noting the events' output to the log.
</p>
```

### Results

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

| Specification |
| --- |
| HTML Standard # event-pageshow |

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

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

See also
--------

* `pagehide`
Window: scrollX property
========================

 The read-only **`scrollX`** property of the
 `Window` interface returns the number of pixels that the document is
 currently scrolled horizontally. This value is subpixel precise in modern browsers,
 meaning that it isn't necessarily a whole number. You can get the number of pixels the
 document is scrolled vertically from the `scrollY`
 property.

Value
-----

 In practice, the returned value is a double-precision floating-point value with the
 range of E(min)=-1022 to E(max)=1023 indicating the number of pixels the document is
 currently scrolled horizontally from the origin, where a positive value means the content
 is scrolled to the left. If the document is rendered on a subpixel-precise device, then
 the returned value is also subpixel-precise and may contain a decimal component. If the
 document isn't scrolled at all left or right, then `scrollX` is 0.

**Note:** If you need an integer value, you can use `Math.round()` to round it off.

 In more technical terms, `scrollX` returns the X coordinate of the left edge
 of the current viewport. If there is no viewport, the returned value is
 0.

Examples
--------

 This example checks the current horizontal scroll position of the document. If it's
 greater than 400 pixels, the window is scrolled back to the beginning.


```js
if (window.scrollX > 400) {
  window.scroll(0, 0);
}
```

Notes
-----

The `pageXOffset` property is an alias for the `scrollX` property:


```js
window.pageXOffset === window.scrollX; // always true
```

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

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

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

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

See also
--------

* `Window.scrollY`
Window: navigation property
===========================

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

The **`navigation`** read-only property of the `Window` interface returns the current `window`'s associated `Navigation` object.

This is the entry point for the Navigation API.

Value
-----

A `Navigation` object instance.

Examples
--------


```js
let currentNavEntries = window.navigation.entries();
```

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

| Specification |
| --- |
| HTML Standard # dom-navigation |

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

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

See also
--------

* Modern client-side routing: the Navigation API
* Navigation API explainer
* Domenic Denicola's Navigation API live demo
Window: opener property
=======================

 The `Window` interface's
 **`opener`** property returns a reference to the window that
 opened the window, either with `open()`, or by navigating
 a link with a `target` attribute.

 In other words, if window `A` opens window `B`,
 `B.opener` returns `A`.

Value
-----

 A `Window`-like object referring to the window that opened the current
 window (using `window.open()`, or by a link with `target` attribute set). If this window was not opened by being linked to or created by
 another, returns `null`.

 If the opener is not on the same origin as the current page, functionality of the
 opener object is limited. For example, variables and functions on the window object are
 not accessible. However, navigation of the opener window is possible, which means that
 the opened page can open a URL in the original tab or window. In some cases, this makes
 phishing attacks possible, where a trusted page that is opened in the original window is
 replaced by a phishing page by the newly opened page.

 In the following cases, the browser does not populate `window.opener`, but
 leaves it `null`:

* The opener can be omitted by specifying
 `rel=noopener` on a link, or passing
 `noopener` in the `windowFeatures` parameter.
* Windows opened because of links with a `target` of `_blank` don't get an `opener`, unless explicitly
 requested with `rel=opener`.
* Having a `Cross-Origin-Opener-Policy` header with a value of
 `same-origin` prevents setting `opener`. Since the new window is
 loaded in a different browsing context, it won't have a reference to the opening
 window.
Specifications
--------------

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

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

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

 The **`Window.parent`** property is a reference to the parent
 of the current window or subframe.

 If a window does not have a parent, its `parent` property is a reference to
 itself.

 When a window is loaded in an `<iframe>`, `<object>`, or
 `<frame>`, its parent is the window with the element embedding the
 window.

Value
-----

A `Window` or `<iframe>` object.

Examples
--------


```js
if (window.parent !== window.top) {
  // We're deeper than one down
}
```

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

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

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

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

See also
--------

* `window.frameElement` returns the specific element (such as
 `<iframe>`) the `window` is embedded into.
* `window.top` returns a reference to the top-level window.
Window: focus() method
======================

Makes a request to bring the window to the front. It may fail due to user settings and the window isn't guaranteed to be frontmost before this method returns.

Syntax
------


```js
focus()
```

### Parameters

None.

### Return value

None (`undefined`).

Examples
--------


```js
if (clicked) {
  window.focus();
}
```

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

| Specification |
| --- |
| HTML Standard # dom-window-focus-dev |

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

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