1

I know you can set the overflow property in CSS to determine what the page does on overflow, but I was wondering if there was any way to listen for page overflow using pure javascript or jQuery?

2 Answers 2

1

You can check by comparing offsetHeight and scrollHeight

var div = document.getElementById('main');
console.log(div.scrollHeight);
console.log(div.offsetHeight);

The element should have overflow: auto/scroll css property.

Working Fiddle (add content in the div to check)

Sign up to request clarification or add additional context in comments.

Comments

0

You can do it with jQuery

$("element").css("overflow");

or

$("element").css("overflow-x");

I recommend you the 2nd example, because it should work in most browsers.

1 Comment

Wouldn't this just return the value of the overflow property? I want to detect if the page has enough content to where it overflows.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.