Document: scrollingElement Eigenschaft

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2020.

Die schreibgeschützte Eigenschaft scrollingElement des Document-Interfaces gibt eine Referenz auf das Element zurück, das das Dokument scrollt. Im Standardmodus ist dies das Wurzelelement des Dokuments, document.documentElement.

Im Quirksmodus gibt das scrollingElement-Attribut das HTML body-Element zurück, wenn es existiert und nicht potenziell scrollbar ist, andernfalls gibt es null zurück. Dies mag überraschend erscheinen, entspricht jedoch sowohl der Spezifikation als auch den Browsern.

Wert

Das Element, das das Dokument scrollt, in der Regel das Wurzelelement (es sei denn, es wird nicht im Standardmodus ausgeführt).

Beispiele

js
const scrollElm = document.scrollingElement;
scrollElm.scrollTop = 0;

Spezifikationen

Specification
CSSOM View Module
# dom-document-scrollingelement

Browser-Kompatibilität

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
scrollingElement

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support