Reputation: 138
Before you say anything I realise there is already very similar questions but they don't give me exactly what I need.
My question is how do I in Javascript stop the user from scrolling but I still get to raise the event with something like this.
window.onload = function()
{
//adding the event listerner for Mozilla
if(window.addEventListener)
document.addEventListener('DOMMouseScroll', moveObject, false);
//for IE/OPERA etc
document.onmousewheel = moveObject;
}
function moveObject(event)
{
//CODE
}
EDIT: And then I need to enable the user to scroll again.
Upvotes: 0
Views: 499
Reputation: 16675
You will need to return false;
from your event handler.
function moveObject(event)
{
//CODE
return false;
}
Upvotes: 1