Is there any way to lock scrollbar?

J

jkarpago

Hi:
I have a javascript that creates a custom scrollbar for a div in the
middle of my page.
The problem is that when I scroll in my div it scrolls the div and the
scroll of the page so I loose the position i want and exists from my
div.

So , what I want is to lock the window scrollbar in the moment I am
over my div, so I can scroll my div without any window movement.

Is this possible?
 
B

bobzimuta

jkarpago said:
Hi:
I have a javascript that creates a custom scrollbar for a div in the
middle of my page.
The problem is that when I scroll in my div it scrolls the div and the
scroll of the page so I loose the position i want and exists from my
div.

So , what I want is to lock the window scrollbar in the moment I am
over my div, so I can scroll my div without any window movement.

Is this possible?

I think the problem you're having is that you scroll the div using the
mouse wheel, and it makes the window scroll. Correct?

If so, you need to prevent the default action for the scrolling event
(which is to scroll the window).

function scrollDiv( e )
{
.... // your code
if( !e ) e = window.event;

if( e.preventDefault )
e.preventDefault();
else
e.returnValue = false;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top