window.scrollTo is not working in mobile phones
I got it finally working.
i had to use additionally the setTimeout function
setTimeout(window.scrollTo(x,y),100);
scrollTo not working in Safari
scrollTo
is a property of window
object. And you are trying to apply it on an element
.
Use
element.scrollTop
Code Snippet
document.querySelector('ol').scrollTop = 100;
It will do the trick!
For more information on scrollTo
& scrollTop
, refer Mozilla/Window/scrollTo & Mozilla/Element/scrollTop respectively.
NOTE
document.querySelector(selectors)
returns the first element within
thedocument
. If yourdocument
contains multiple<ol>
elements,
it will always return the first element.To select specific element, you can assign an
ID
& refer the element
bydocument.querySelector('#ID')
.
Hope it helps!
windows.scroll working in chrome but not in safari
You could try scrollTo
window.scrollTo(0, 0);
https://www.w3schools.com/jsref/met_win_scrollto.asp
Lists browsersupport for Safari
Related Topics
Launch Chrome Browser from Internet Explorer
Youtube API - Failed to Execute 'Postmessage' on 'Domwindow'
Filtering Item from Nested Object Array in Typescript
Show Only a Limited Number of Rows in a Table
Javascript Sum and Group by of Json Data
Slick Carousel - Force Slides to Have the Same Height
Calculate Percentage JavaScript
Calculate and Display % Discount for Price Classes JavaScript
How to Read Data from *.Csv File Using JavaScript
Reverse Strings Without Changing the Order of Words in a Sentence
How to Make an Area Unclickable With CSS
Why Is the Onclick Event Triggered Twice
How to Match Only the Exact Word Using Indexof or Includes in JavaScript
How to Show a Confirm Message Before Delete
Get Array of Values from Multiple Inputs Using Jquery