javascript disable scrolling

document.body.style.overflow = 'hidden';

4.71
7
Rabica P 100 points

                                    function disableScrolling(){<br/>    var x=window.scrollX;<br/>    var y=window.scrollY;<br/>    window.onscroll=function(){window.scrollTo(x, y);};<br/>}<br/><br/>function enableScrolling(){<br/>    window.onscroll=function(){};<br/>}

4.71 (7 Votes)
0
4.17
6
QueenSaphos 115 points

                                    // left: 37, up: 38, right: 39, down: 40,
// spacebar: 32, pageup: 33, pagedown: 34, end: 35, home: 36
var keys = {37: 1, 38: 1, 39: 1, 40: 1};

function preventDefault(e) {
  e.preventDefault();
}

function preventDefaultForScrollKeys(e) {
  if (keys[e.keyCode]) {
    preventDefault(e);
    return false;
  }
}

// modern Chrome requires { passive: false } when adding event
var supportsPassive = false;
try {
  window.addEventListener(&quot;test&quot;, null, Object.defineProperty({}, 'passive', {
    get: function () { supportsPassive = true; } 
  }));
} catch(e) {}

var wheelOpt = supportsPassive ? { passive: false } : false;
var wheelEvent = 'onwheel' in document.createElement('div') ? 'wheel' : 'mousewheel';

// call this to Disable
function disableScroll() {
  window.addEventListener('DOMMouseScroll', preventDefault, false); // older FF
  window.addEventListener(wheelEvent, preventDefault, wheelOpt); // modern desktop
  window.addEventListener('touchmove', preventDefault, wheelOpt); // mobile
  window.addEventListener('keydown', preventDefaultForScrollKeys, false);
}

// call this to Enable
function enableScroll() {
  window.removeEventListener('DOMMouseScroll', preventDefault, false);
  window.removeEventListener(wheelEvent, preventDefault, wheelOpt); 
  window.removeEventListener('touchmove', preventDefault, wheelOpt);
  window.removeEventListener('keydown', preventDefaultForScrollKeys, false);
}

4.17 (6 Votes)
0
5
2
Ssav 80 points

                                    function scrolldown() {
  setTimeout(
    function()
    {
      window.scrollTo(0,document.body.scrollHeight);
      scrolldown();
    }, 2000
  )
}

scrolldown()

5 (2 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
disable scroll page javascript how to disable scrollbar javascript javascript disable scrolling down how to disable scrollbar in html javascript disable scroll in javascript javascript how to disable site scrolling javascript keep scrolling down disable scroll javascript body disable scrollin js disable scroll with javascript how to turn off scrolling in javascript disable scrolling javascripy esri javascript disable scrolling scroll disable js disable scrolling windows javascript intro js disable scroll javascript disable page scroll disable scroll javascript info disable scroll ina window javascript vanilla js disable scroll on body how to disable scroll bar in js how to disable scrolling js javascript disable body scroll disable enable scrolling javascript disable scroll in js html5 js disable scroll on body javascript is disabled enable scrolling disable scroll down javascript disable and enable scroll javascript Disable Scrolling with JavaScript js disable scroll on element disable scrolle js disable page scrolling javascript javascript how to disable scroll disable page scroll js js disable scroll block disable scroll wheel javascript disabled and enable scroll in js how to disable scroll with javascript javascript disable html scroll disable window scroll with javascript window disable scrolling html how to disable scrolling down javascript window disable scroll js javasacript disable scroll javascript disable scroll page ajavascript disable scroll keep scrolling using javascript javascript disable scroll css body disable scroll display when scroll up js check scroll up js js disable scrolling in div disable auto scrolling js js disable page scroll how to disable page scroll in javascript disable stop scrolling javascript disable scroll event javascript javascript disable scrollbar disable bodyscroll js how to disable scroll using js js disable and reinable scrolling disable scrolling in javascript how to disable scroll javascript javwcript disable scroll how to disable page scrolling javascript how to disable scroll js way disable horizontal scrolling javascript how to keep scrolling down javascript how to keep scrolling javascript html height 100% stop scroll event fire prevent scroll global div js prevent browser scrlling how to prevent modal from making the page to the top how to prevent modal from scrolling the page to the top disable modal body page disable model body page modal is not scrolling but background page is scrolling remove block on the certain position on scroll js css disable scrolling javascript block page scrolling till 50% do not scroll on window increase prevent scroll when modal open jquery how to disable background scroll on modal how to stop body scroll js css modal background scroll how to disable window scroll in javascript scroll somewhere by javascript how to disable scrolling javascript how to prevent body from scrolling when modal window open page is scrolling when modal is open using jquery remove scroll trigger javascript page is scrolling when modal is open javasript block scroll on page disable scroll while loading pure javascript stop user from scrolling javascript block scroll event croll precent disable auto scroll after close modal box disable scroll disable on modal open scroll lock stop auto scroll animation modal prevent background scrolling keep modal still css how I check which element is scrolling javascript how to disable background scrolling when popup modal is open prevent page scrolling on modal background scrools model does not scroll disable scrolling temporarily using angular 8 how to disable scrolling temporarily using angular 8 windowScrolling.disable(); modal stop scrolling background how to remove scroll-behaviour from html page when I select something js on window scroll blockScroll how to remove event scroll in mobile by js prevent scrolling based on a condition carasouel sllider prevent scrolling based on a condition js stop scroll of other elements when open prevent scroll when modal open no scroll when modal is open disable body scroll javascript disable scrolling javascxript css disable scroll on body disable can scoll Disabling body scroll with Modal how to disable scroll when modal how to disable scroll when modal with css how to disable scroll when modal is open modal popup no scroll with page stop the default scrollbar of the page after scrollevent modal disable scrolling stop scrolling imidiatly js stop scrolling js prevent scroll by js window.scrollto prevent inside div disable scroll body javascript disable scroll body how to disable scrolling after a modal pops up bootstrap 4 modal disable scroll on body Prevent scroll down disable document scroll js how to disabled scroll how to make the the page unscrollable when model is shown how to stop scroll item js top scrol how to stop scrool javascript click to scroll off if window scroll javascript css disable window scroll javascript disable window scroll lock the page scroll on modal is open rememeber scroll position javascrip javascript freeze scrolling jquery load modal disable scroll scrollx scrolly javascript javascript how to force disable scrolling on an element of a div scrolltop javascript restrict mousewheel window.scrolly stop page scrolling js disable user scroll remove scroll behaviouir on div jquery scroll preventdefault scroll event js scrollby javascript javascript on scroll event disable onscroll function disable onscroll event window.scrollBy How to prevent BODY from scrolling when a modal is opened Using jQuery ? javascript stop page scrolling disable scroll event on adding new element to dom disable scroll at the time of states changing prevent scrolling too quickly vanilla javascript get scroll position js on div scroll javaescript document.body.scroll = &quot;no&quot;; scrollintoelement javascript window no scroll js window.scrollto scroll off on some event scrollheight javascript css scroll prevention on modal when displaying a modal how to disable background scroll prevent scrolling css javascript don't scroll prevent scrolling angular disable scrolling in js disable scroll when modal is open prevent temporary window scroll prevent window scroll javascript scroll event iwhen modal open page scroll hide stop body from scrolling css disable scroll on sclick typescript when click block scrolling js scroll page javascript body scroll how to stop that disable scrolling css how to stop scrolling if already scrolling in javascript how to stop scrolling in javascript enable disable scrolling how to diable scrollling in js js desativate scroll prevent scrolling with js when modal open disable background scroll make scroll disable window scroll event disable disable and enable scroll avoid scroll over page css how to lock scrolling css how to restrict scroll bootstrap modal without oveflow hidden css html overflow hidden for window disable javascript off scroll elements this windowScrolling.disable() typscript disable scroll with js background scrolling modal box javascript scrolltop javascript scrollby javascript scroll block script blocking scroll js prevent window from scrolling down javascript scroll trong javascript how to stop scroll javascript how to disable ability to scroll javascript window scrolltop javascript javascript preventdefault scroll how to disable scrolling in js javascript do not allow to scroll disable background scrolling modal window.scrollto block prevent bootstrap modal from scrolling take off scroll in modal on modal my back screen is scrolling boostrap modal with scroll i the background block global scrolling scrolling is disable on dynamic data loading, android how to disable scroll js window prevent scroll stop scroll ability when modal open js html scroll disabled on search open scroll false js disable window scroll javascript how to stop scrolling in css when dialog box prevent page scrooling modal boostrap prevent page scrooling modal prevent window from scrolling javascript prevent scrolling how to enable scroll with document in javascript disable background scroll on modal how to temporarily disable scrolling javascript document fotbid scroll window scroll block/unblock js block scrollbar js document.body overflow hidden how to disable div scroll onclick disable window scroll onclick how to disale scroll prevent scrolling behind modal js scrollheight set scroll by javascript how to prevent scroll when modal is open SCROLLING DISABLE diable page scroll modal disable scroll down js disable scroll inside modal moble how to scrolling off javascript prevent scrolling disable scrolling when modal is open js no scrolling disable scroll outside modal disable bage scroll onclick prevent body scrolling javascript prevent body scrolling javascript modal scroll background e preventdefault scroll js no scroll bootstrap modal scroll outside stop scroll when modal opene modal stop background scrolling off how to popup bootstrap body scroll hide when popup is open css scroll then stop scrolling block scroll down up bootstrap modal disable document scrollbar javascript scrolling stop remove scrolling from element prevent scrolling in js js stop default scroll how to disable background scrolling when popup modal is open in mobile javascript disable window scroll when modal open stop background scroll on bootstrap modal Javascript prevent scrolling on body stop the scrolling of the background modal css remove background scroll bootstrap modal noScroll js stop background scroll on modal open bootstrap stop scroll when modal open how to stop scrolling using ja disable scroll on element android disable windows scrolling when range stop background scrolling modal js window prevent scrolling ghow to set window to fixed when modal is open prevent # from scrolling javascript javascript scroll privent bootstrap modal background scrolling stop body from scroll bootstrap javascirpt noScroll prevent windowscroll how to prevent scrolling in js prevent user from scrolling disable scroll all screen bootstrap modal prevent scrolling background eliminate scroll when modal open html stops me from scrolling up in modal how to stop user from scrolling when modal window open java block scroll window stop scroll disable page scroll when modal is open prevent scroll on scroll disable scroll but not scrollevent js disallow scroll diable scroll temporarily jquery cancel scroll event in course jquery cancel scroll event and go to top of window block scroll when modal is open jquery prevent scroll for time disable body overflow 'prevent-scroll' javascript keep scrolling till condition bootstrap modal popup background scroll disable js stop scrolling disable html scroll wwhen modal is open dilete scroll body then creat scroll body js disable scroll with event lock scrolling javascript bootstrap 3 model open then body scroll disable css disable scroll in js javascript disable scroll to top disable scroll y on clivk css disasable scroll js javascript block window scroll Prevent Page Scrolling When a Modal is Open prevent background scroll when modal open disable scroll in js' how to block scroll stop the default scrolling disable scroll on body javascript block scrolling on body css prevent scrolling modal cancel window scroll disable a div after some scrolling js prevent scrolling page when modal is open disable scroll jq disable scroll event javascript prevent body scrolling disable background scroll on modal open js block scroll disable scrolling on document window scrolls to top on button click disable desactivate scroll disable scroll temporarily disable page scroll javascript diable scroll bootstrap 4.5.2 modal stop scrolling behind bootstrap modal stop scrolling behind modal-dialog-scrollable prevent scroll left right disable body scroll when modal is open maintain scroll position disable body scroll when modal is open how to block scrolling body stop scrolling javascript document no scroll css document no scroll js how to disable scroll javascript disable all scrolling stop page scroll when modal open modal scroll disable prevent scroll js stop scroll efect when find an element how to disable scrolling on page css js prevent scroll how to disable scroll in js evoid scroll itermm2 stop scroll disable scroll on event hop wto trigger scroll aniamtions with temporary scrollbar stop page scrolling behind modal how to allow scrolling for rest of page when bootstrap modal is open javascript noscroll eventlistern disbale for clickscroll disable-scroll javascript prevent user from scrolling how to diasable scrolling restrict scrolling of element disable scroll with # prevent on scroll how to prevent scroll-behaviour from scrolling when html loads disable scroll selection html5 prevent modal scrolls to end start scrolling body prevent body scroll javascript disable scrolling past window.innerheight disable document scroll typescript browser back prevent scroll top js document overflow hidden prevent page scrolling when modal is open css modal position fixed scroll y on focus disable scrolling to element a jquery prevents me from scrolling down can i block scroll in javscript remove on scroll js js stop page from scrolling down block scroling with javascipt disable function page up js how to prevent scrolling in javascript block document scrolling how to keep scrolling with javascript modal scrollinstead of modal background is scroll css\ instead of mdoel backgroudn is scroll css\ js modal active disable scroll jquery toggle diable window scroll stop scroll stopSroll disable all scrolls angular how to stop scroll when it scrolls avoid to scroll until element how to lock screen to no scroll website javascript start stop scroller js block scroll down how to let body scrollbar control popup window in html javascript disable scrolling on body prevent scroll javascript javascript disable the scroll how stop hide data while scrolling javaScript how stop remove data while scrolling javaScript prevent screen from scrolling with javascript how to prevent scrolling disable and scroll one button javascript disable scroll on click javascript disable scroll css javascript prevnet scroll javascript disable scroll window javascript how to stop and hide the scroll buttons when reached the end of the file js stop scrolling with scrollbar javascript block scrolling lock scroll event how to disable onscroll=&quot;&quot; with css how to disable onscroll javascript css block scroll javascript css scroll in block make scroll off javascript scroll false disable scrolling stop scrolling no scroll javascript freeze scrollbar javascript Disables body scroll while enabling scroll on target element disable scrolling js block page scrolling by javascript js disable scrollling disable user scroll javascript stop page to scroll up on scroll vent prevent user from scrolling javascript how to prevent windowns scroling to right css prevent scroll lock scroll javascript how to disable scroll in javascript how to stop scroll up in javascript scroll page block at scrolling javascript window scroll disable javascript window disable scroll javascript catch before scroll and prevent it lock scroll js css disable scroll page wheel scroll return false freeze scrolling in javascript js prevent scrolling disble window onscroll javcript prevent page scroll javascript prevent page scroll disable scroll lock javascript prevent scroll in javascript window .do not scroll in js disable scroll javascript block page scroll disable scroll js disable scrolling javascript window no scroll js globally lock scrolling enable scroll vanilla js javascript stop scrolling react disable scroll events on current component only force window to not scroll stop scrolling javascript disable window scroll css how to not scroll js sdisable scroll in page how to disable scrolling javascript prevent scroll prevent scrolling javascript js disable scrol;ling javascript disable scroll how to stop scrolling on window javascript window scroll disable js prevent scroll how to stop the user from scrolling js prevent scrolling javascript block scroll js disable scroll js stop scroll until scroll div effect disable disable scroll javascript js disable scrolling javascript no scroll how to stop js from making page scroll to botto javascript disable scrolling how to stop srolling in js when action disble scroll with js how to disable the scroll on html from button prevent scroll pure js block scroll js javascript avoid scroll
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source