Sebi Kovacs
Sebi Kovacs

Reputation: 38

Javascript - is there an alternative for element.scroll or element.scrollTo in Safari?

I've just noticed that the .scroll and scrollTo methods are undefined when invoked on DOM elements in Safari. Chrome and Firefox seem to handle the issue right.

I've added this jsfiddle to ilustrate the problem. Open it in Chrome, Firefox and Safari to and check the Console panel. I'm on a mac, by the way.

Do you know of any alternative or woraround?

Upvotes: 1

Views: 1457

Answers (2)

GOTO 0
GOTO 0

Reputation: 47801

The .scrollLeft and .scrollTop properties are well supported in current browsers, including Safari, and can be used to get or change horizontal and vertical scrolling offset.

element.scrollLeft = x;
element.scrollTop  = y;

Upvotes: 2

Angular Dev
Angular Dev

Reputation: 4916

Chrome is throwing undefined for me as well. I think these methods are only window methods see w3 schools reference here.

Upvotes: 0

Related Questions