Categories
JavaScript Answers

How to disable browsers vertical and horizontal scrollbars with JavaScript?

Spread the love

Sometimes, we want to disable browsers vertical and horizontal scrollbars with JavaScript.

In this article, we’ll look at how to disable browsers vertical and horizontal scrollbars with JavaScript.

How to disable browsers vertical and horizontal scrollbars with JavaScript?

To disable browsers vertical and horizontal scrollbars with JavaScript, we can set the overflow style to 'hidden'.

For instance, we write

document.documentElement.style.overflow = "hidden";

to hide the scrollbars on the page by setting document.documentElement.style.overflow to 'hidden'.

We can restore the scrollbars with

document.documentElement.style.overflow = "auto";

Conclusion

To disable browsers vertical and horizontal scrollbars with JavaScript, we can set the overflow style to 'hidden'.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *