Languages
[Edit]
EN

JavaScript - stop page scroll with e.preventDefault()

4 points
Created by:
Root-ssh
178430

In this short article, we would like to show how to use e.preventDefault() to stop onscroll event with JavaScript.

Quick solution:

Note: go to this article to see pure CSS.

 

Practical example

Edit

Depending on what device we use, we need to handle scrolling occurred by mouse wheel, scrollbar dragging and touch moving.

See also

Edit
  1. CSS - disable scroll bar 

Alternative titles

  1. JavaScript - disable scrollbar
  2. JavaScript - block scrollbar
  3. JavaScript - disable scrolling
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join