1

Is it possible to disable scrollbar without overflow:hidden in jQuery ?

And without $(window).bind("scroll", function() { scroll(0,0); });

which works but the scrollbar is always active and it backs to top immediatly.

UPDATE : Is there a way to put an PreventDefault() when a user click on scrollbar ?

8
  • 1
    What are you trying to do? Do you want the scrollbar visible? And why are you doing this? Commented Sep 11, 2011 at 14:59
  • When I do overflow:hidden, my main div will move to the right (around 10px) because there is no scrollbar yet. Commented Sep 11, 2011 at 15:04
  • Then add a right-hand margin of 10px Commented Sep 11, 2011 at 15:07
  • Hmm... yeah but the scrollbar's width is not the same for each browser Commented Sep 11, 2011 at 15:10
  • Sorry, why is this so important? If your div is in the middle of the page use margin:0 auto; Otherwise use position:absolute; and position it relative to the left. Commented Sep 11, 2011 at 15:11

1 Answer 1

1

I can't think of a way to do this from javascript ONLY, without setting the css param overflow:hidden (either manually, or from javascript). Why is it that overflow:hidden is not a good option for you?

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

4 Comments

then adjust it with padding, margin, or position:relative.
Hmm... yeah but the scrollbar's width is not the same for each browser
You can make the div's position absolute: position:absolute; top: 140px; left: 87px;
UPDATE : Is there a way to put an PreventDefault() when a user click on scrollbar ?

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.