window.scrollTo() scrolls to a particular set of coordinates in the document (MDN). Pass (x, y) or an options object with top, left, and behavior. For a relative nudge from the current spot, use scrollBy().
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax
Call window.scrollTo. Start with this line.
JavaScript
scrollTo(x, y) or scrollTo(options)
Call
What it does
scrollTo(x, y) or scrollTo(options)
Primary signature.
window.scrollTo(...)
Call with the arguments your case needs.
Built into the browser. Call window.scrollTo(...) (or the global scrollTo(...)) — no import required.
Library declarations
JavaScript
scrollTo(x, y) or scrollTo(options)
Parameters
Parameter
Description
options.behavior
Optional. smooth, instant, or auto
Return Value
Return Value
Description
*
Promise<{ interrupted }> (support varies)
JavaScript Examples
Example 1 — Jump to Coordinates
MDN basic usage: scroll to an absolute document position.
Smooth note. With behavior: "smooth", read again after animation if needed.
Compatibility
Browser Support
Window.scrollTo() is marked Baseline Widely available on MDN (since July 2015). It is not Deprecated, Experimental, or Non-standard. Promise return / interrupted may vary — feature-detect if you depend on it. Browser Window API — not a Node.js built-in.
✓ Baseline · Widely available
scrollTo()
Scroll the document to absolute coordinates across modern browsers.
99%Core tag support
ChromeYes
Full support
EdgeYes
Full support
FirefoxYes
Full support
SafariYes
Full support
OperaYes
Full support
HTML element100% supported
Bottom line: Safe for modern apps. Prefer options + behavior for smooth UX; detect Promise support before awaiting.
Frequently Asked Questions
It scrolls the document to a particular set of coordinates (MDN). scrollTo(0, 500) moves so the viewport’s top-left is at document position (0, 500), unless clamped at the edges.
No. MDN marks Window.scrollTo() as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard. Some parts (such as the Promise return) may vary by browser.
MDN documents a Promise that fulfills with { interrupted }. interrupted is true if another programmatic scroll started on the window before the first finished. Feature-detect if you rely on the Promise.
scrollTo(x, y) sets an absolute position. scrollBy(dx, dy) adds a relative delta from where you are now. Use scrollTo for “go to top” or a known coordinate; use scrollBy for “move one screen from here.”
Optional string: smooth (animate), instant (jump), or auto (use the computed CSS scroll-behavior). Default is auto (MDN).
scrollIntoView() is usually simpler for a target element. Prefer scrollTo when you need exact document pixel coordinates (for example back-to-top at 0, 0).