Disable browsers vertical and horizontal scrollbars

后端 未结 11 2317
一生所求
一生所求 2020-11-28 02:41

Is it possible to disable the browsers vertical and horizontal scrollbars using jQuery or javascript?

相关标签:
11条回答
  • 2020-11-28 03:34

    Because Firefox has an arrow key short cut, you probably want to put a <div> around it with CSS style: overflow:hidden;.

    0 讨论(0)
  • 2020-11-28 03:35

    Using JQuery you can disable scrolling bar with this code :

    $('body').on({
        'mousewheel': function(e) {
            if (e.target.id == 'el') return;
            e.preventDefault();
            e.stopPropagation();
         }
    });
    

    Also you can enable it again with this code :

     $('body').unbind('mousewheel');
    
    0 讨论(0)
  • 2020-11-28 03:43

    In case you also need support for Internet Explorer 6, just overflow the html

    $("html").css("overflow", "hidden");
    

    and

    $("html").css("overflow", "auto");
    
    0 讨论(0)
  • 2020-11-28 03:46
    function reloadScrollBars() {
        document.documentElement.style.overflow = 'auto';  // firefox, chrome
        document.body.scroll = "yes"; // ie only
    }
    
    function unloadScrollBars() {
        document.documentElement.style.overflow = 'hidden';  // firefox, chrome
        document.body.scroll = "no"; // ie only
    }
    
    0 讨论(0)
  • 2020-11-28 03:47

    Try CSS

    <body style="overflow: hidden">
    
    0 讨论(0)
提交回复
热议问题