window.scrollTo not working in iOS chrome

arun15thmay picture arun15thmay · Feb 8, 2016 · Viewed 7.8k times · Source

We are using javascript code to scroll to a div with the given ID. I tried to use

jQuery.animate({scrollTop: number})

window.scrollTo(0, number) 

setTimeout(function() {window.scrollTo(0, number);}, 1000)

I also tried to add #element_id to the url to scroll to the element_id.

None of these options are working. Is there any way to get it to work?

iOS: 9.2.1

Chrome: 48.0.2564.87

http://jsfiddle.net/fXx6c/114/

Answer

Allure Web Solutions picture Allure Web Solutions · Jun 6, 2017

You can use window.scroll() instead. I tested in your jsfiddle and it worked. Usage would be the same as window.scrollTo().

For example: window.scroll(0, 485);

This answer might explain why window.scrollTo doesn't work