[Solved] How to disable scrolling temporarily? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

[Solved] How to disable scrolling temporarily?

Is there a way to toggle between allowing and not allowing scrolling in HTML (using JavaScript)? I've tried using "overflow:hidden" for the body, but it didn't work. (I'd like to make it so that you can't scroll while your aiming because otherwise you can't aim properly.) https://code.sololearn.com/Wz1o64t7s7eg/?ref=app

9th Jun 2022, 10:00 AM
C. Scheler
C. Scheler - avatar
3 Answers
+ 2
You could controll it with: position: fixed; for #ground or whole body.
9th Jun 2022, 11:35 AM
JaScript
JaScript - avatar
+ 1
JaScript Thanks! I had tried a similar approach before, but I had done it wrong.
9th Jun 2022, 11:57 AM
C. Scheler
C. Scheler - avatar
+ 1
Cool C. Scheler , nothing is wrong if it works. In coding are often more than one different solutions. Happy coding!
9th Jun 2022, 12:31 PM
JaScript
JaScript - avatar