JavaScript - How to disable document body from scrolling

Asked By Erik Little on 12-Apr-09 12:56 AM

I am using the new slider controls in a webform; however, these slider controls make the entire document scroll up when moving the slider handle.

This is a know issue.

My questions is.. Does anyone know how to lock or prevent the docment body from scrolling at all.

I will just put a client button on the webform and have Lock Page as the text for the button. So when the button is clicked the document body is Locked from scrolling.

Can this be done?

Try this - Sathish S replied to Erik Little on 12-Apr-09 01:22 AM


<body onscroll="scrolltop();" >


<SCRIPT type="text/javascript" language="Javascript">

// You need to set 'stop_scroll = true' to disable scroll completely
// You can also set to true using a function to disable on an event

var stop_scroll = false ;

function scrolltop(){
    if(stop_scroll ==true){
        scroll(0,0) ;

hope ths helps - alice johnson replied to Erik Little on 12-Apr-09 01:32 AM

function OnClientShow(radWindow)
if (document.all)
document.body.scroll "no";
var oTop = document.body.scrollTop;
                document "hidden";
.body.scrollTop oTop;

function OnClientClose(radWindow)
document.body.scroll "";
            document "";
form id="Form1" method="post" runat="server">
<radW:RadWindowManager id="RadWindowManager1" 
= "OnClientShow"
= "OnClientClose"

Thanks - Erik Little replied to alice johnson on 12-Apr-09 01:48 AM

Works great in FF but no IE.

IE is the browser that is giving me the trouble.

Any suggestions?

IE vs FF.. - Santhosh N replied to Erik Little on 12-Apr-09 02:01 AM
Thats the issue with document.body.scrollTop being not recognized correctly in IE,

You can check here for alternatives in changing the Doctype of the page and other techniques to make it work in both...
Thanks - Asked By Erik Little on 12-Apr-09 01:50 PM

Got it thanks to all the help... !

Thanks for all the help..

<script name="Add and Remove Scroll Bars" type="text/javascript">

function noScrollIE() {

document.body.scroll = "no"; = 'hidden';

scroll(0, 275);


function scrollIE() {

document.body.scroll = "yes"; = 'scroll';


function noScrollNS() {

document.width = window.innerWidth;

document.height = window.innerHeight;


function scrollNS() {

document.width = 1000;

document.height = 1000;



<script name="Do the work" type="text/javascript">

function LockPage() {

if (browser = "Internet Explorer") {



else if (browser = "Netscape Navigator") {




function UnLockPage() {

if (browser = "Internet Explorer") {



else if (browser = "Netscape Navigator") {





Ryan replied to Erik Little on 01-Sep-10 09:35 PM
Is there any way to do this to just prevent horizontal scrolling?
Miqdad Ali replied to Erik Little on 27-Jul-11 12:26 AM
$("html").css("overflow", "hidden");   // for disable


$("html").css("overflow", "auto");    //for enable

you should use a jquery packeage
Miqdad Ali replied to Miqdad Ali on 12-Aug-11 12:41 AM
Thanx Miqdad its working fine.................