About Scroll Determination During No Scroll

Asked 1 years ago, Updated 1 years ago, 25 views

Is it possible to change html, body to overflow:hidden, etc. and do something if you try to scroll when you can't scroll?

Also, if possible, please let me know the source code.
Please m(__)m

javascript

2022-09-30 19:22

1 Answers

I think you can do it if you change the example below a little bit.
When you run this snippet, an alert appears and the text changes.

var message= document.getElementById("message");
document.addEventListener("wheel", function(e){
  e.preventDefault();
  message.textContent = "Do not scroll";
  alert("Scrolling is prohibited");
});
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<pid="message">Scroll </p>
</body>
</html>


2022-09-30 19:22

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.