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'
.