window.scroll with options object used in scrollToHash is not supported in IE, Edge, Safari and older versions of Chrome
See original GitHub issueIn scrollToHash function window.scroll
method is called with options object. Unfortunately, this syntax is not supported by IE, Edge, Safari and older versions of Chrome (MDN docs), which only support the old syntax, i.e. window.scroll(x-coord, y-coord)
.
Top 3 JS errors on our site reported by TrackJS are caused by this issue 😕 Unfortunately some browsers that don’t support it don’t throw any error and simply scroll to 0, 0
, but e.g. older versions of Chrome (e.g. 55, even though it should work according to MDN) throw the following error:
Failed to execute 'scroll' on 'Window': No function was found that matched the signature provided.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:9
Top Results From Across the Web
window.scrollTo with options not working on Microsoft Edge
This code correctly scrolls the window 1000px to the left and down, with a smooth behaviour in Chrome and Firefox. However, on Edge...
Read more >Set up Legacy Browser Support for Microsoft Edge in IE mode
Option 1: IE sitelist Admin console—On the Users & browsers settings page, scroll to Use Internet Explorer site list and select Use Internet...
Read more >Window.scrollTo() - Web APIs | MDN
Window.scrollTo() scrolls to a particular set of coordinates in the document. ... scrollTo(x-coord, y-coord) scrollTo(options)
Read more >Supported browsers for Outlook on the web and Outlook.com
Learn about the supported browsers and system requirements for using Outlook.com.
Read more >Configuring your web browser to allow pop-up windows
Safari (macOS) · From the Safari menu, choose Preferences... and click the Security tab. · Ensure the Block pop-up windows option is not...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is definitely something that needs fixing then. I hadn’t realized that such recent browsers didn’t support this.
Perhaps the best approach is to just use the old syntax, and leave smooth-scrolling to the user through a scroll-behavior css property. Does this sound reasonable?
Navi 0.12.8 will now use the old form of
window.scroll
by default.To opt in to smooth scrolling, you have a couple options:
hashScrollBehavior='smooth'
prop to<Router>
or<NaviProvider>
<HashScroll behavior='smooth'>
component