js禁止滚动条移动

js禁止滚动条移动

var scrollFunc=function(e){
    e=e||window.event;
   if (e&&e.preventDefault){ 
        e.preventDefault();
        e.stopPropagation();
    }else{ 
     e.returnvalue=false;  
     //return false;     
    }
}

js通过隐藏滚动条禁止其移动

document.body.parentNode.style.overflow = “hidden";//隐藏且禁用横向纵向两个滚动条
document.body.parentNode.style.overflow = “auto";//开启横向纵向两个滚动条
document.body.parentNode.style.overflowX = ”hidden“;//隐藏横向滚动条

document.body.parentNode.style.overflowX = ”auto“;//开启横向滚动条

document.body.parentNode.style.overflowY = ”hidden“;//隐藏纵向滚动条

document.body.parentNode.style.overflowY = ”auto“;//开启纵向滚动条

 

posted @ 2015-02-02 11:02  werqrqrqwerwr  阅读(1534)  评论(0编辑  收藏  举报