question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

window.scroll with options object used in scrollToHash is not supported in IE, Edge, Safari and older versions of Chrome

See original GitHub issue

In 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:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:9

github_iconTop GitHub Comments

4reactions
jamesknelsoncommented, Mar 24, 2019

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?

2reactions
jamesknelsoncommented, Jun 12, 2019

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:

  • pass a hashScrollBehavior='smooth' prop to <Router> or <NaviProvider>
  • wrap your app in a <HashScroll behavior='smooth'> component
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found