1

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..

4
  • 1
    It looks like you've got some improperly-nested tags or something. By the way, that piercing noise you have on mouse over of the links is one of the worst things I have ever seen. You should remove it, nobody wants a website that hurts your ears. Commented Sep 2, 2010 at 1:56
  • Can you scroll horizontally when the vertical scroll bar appears? Commented Sep 2, 2010 at 1:57
  • notjim - yeah i hate that noise too but thats what the client wanted. rmarimon - im not sure i understand your quesion. Commented Sep 2, 2010 at 2:32
  • 1
    On my Chrome browser, there's no horiz scroll for your site, but as a result I could not see the entire width of your page unless I resized the browser. And for people with regular sized screens (I have a large size, heh), that may not be an option. Commented Sep 2, 2010 at 4:19

3 Answers 3

2

It seems that you put overflow-x: hidden in the HTML body; however this will not work. Use overflow-x: hidden on the element that you wish to disable horizontal scrolling.

Sign up to request clarification or add additional context in comments.

2 Comments

He means owerflow-x: hidden;.
Or maybe överflow-x: hidden?
0

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>

Comments

0

You can try this workaround

$(window).on("scroll", function(evt) {
var height = $(window).scrollTop();
scrollTo(0,height);
});

See my bin here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.