1

I'm scrolling a chat box as new messages come in, and it works fine in Firefox and Chrome incognito, but not normal Chrome. What could be the reason behind this?

My simple scrolling code:

var container = document.querySelector(".dc-messages-container");
container.scrollTop = container.scrollHeight;

3 Answers 3

1

Your script won't work in Chrome unless you set the container style to overflow: auto, or overflow: scroll. Chrome simply ignores the element.scrollTop setter otherwise.

So, your script is fine, styles are missing.

0

It works in chrome. Here's a JSFiddle scrollTop test

My Chrome version is 55.0.2883.87

It may not work if the scrollbar doesn't belong to the element on scrollTop is being set.

0

It does work in chrome.

However, because you're specified that it works in Incognito Mode but not Normal Chrome for you, it seems likely you might have an extension installed which is doing something to the web pages that changes expected behaviour.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.