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/
Definition and Usage The scrollTo() method scrolls the document to specified coordinates.
If you look to the right side of your keyboard, you'll see four arrows: up, down, left, and right. You can use the down arrow to scroll down on a web page and the up arrow to scroll back up.
To scroll the page with JavaScript, its DOM must be fully built. For instance, if we try to scroll the page with a script in <head> , it won't work. Regular elements can be scrolled by changing scrollTop/scrollLeft . We can do the same for the page using document.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With