javascript - Completely disable scrolling of webpage -


this question has answer here:

i want disable scrolling webpage, completely, not disable scrollbars

overflow: hidden 

will not work.

also workaround not apply on macs due "soft-scroll" on edges. show terrible shaky animation:

window.onscroll = function () { window.scrollto(0,0); } 

is there other method disable scrolling completely?

presuming simplified html code is:

<html><body><div class=wrap>content...</div></body></html> 

set both body, html height:100%;

body, html {height:100%;} 

put div inside body, , set stretch across body height:

div.wrap {height:100%; overflow:hidden;} 

this prevent window scrolling in weird ways, like, pressing mouse wheel , moving it, using anchors, etc.

to remove scroll bar (visually), should add:

body {overflow: hidden; } 

to disable scrolling via pressing arrow keys on keyboard:

window.addeventlistener("keydown", function(e) {     // space, page up, page down , arrow keys:     if([32, 33, 34, 37, 38, 39, 40].indexof(e.keycode) > -1) {         e.preventdefault();     } }, false); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -