tags:

views:

58

answers:

2

Hello all,

Does anyone know if there is a way to prevent the user from being able to scroll horizontally? ive used overflow-x:hidden css, but it can still sometimes scroll (but only sometimes, its weird..)

http://www.kaiserroof.com

Would it be possible to disable keystroke events for right/left arrows as well as left/right mousewheel with javascript? if there is no horizontal scrolling, they wouldnt need those buttons anyway. I thought there was a way to do this with javascript, but i cant remember? like onkeypress "left arrow" return false? i dont know too much javascript though..

A: 

it seems that you put the overflow-x:hidden in html body. but the element can inherit or not. just use the ouverflow-x hidden to describes the element which you use scroll bar.

huangli
He means `owerflow-x: hidden;`.
Cipi
Or maybe `överflow-x: hidden`?
deceze
A: 

I figured it out with jquery if anyone wants to know:

<script language="JavaScript"><!--
function checkKey(e){
     switch (e.keyCode) {
        case 37:
            return false;
            break;
        case 39:
            return false;
            break;
        default:
            return true;  
            }      
}

if ($.browser.mozilla) {
    $(document).keypress (checkKey);
} else {
    $(document).keydown (checkKey);
}
--></script>