2012-04-09 61 views
0

即使寿。滚动是“否”,溢出隐藏,浏览器不显示滚动等,但我可以通过鼠标中键滚动。我希望用户无论如何都无法滚动。 另外,框架集有:rows =“50,*”,框架内的东西不再高于50高度px,它可以滚动几个像素。如何让框架不可滚动?

+0

你有一个在线的例子...也许是一个小提琴? – Connor 2012-04-09 22:45:43

+0

http://stackoverflow.com/questions/4770025/how-to-disable-scrolling-temporarily – miqbal 2012-04-09 22:46:42

+0

你仍然可以用键盘按住shift + arrow向下滚动。 – magallanes 2012-04-09 23:01:05

回答

2

在iframe中添加以下代码:

$(document).on('mousewheel keydown', function (event) { 

    //if the mousewheel event is being fired or if a keydown event with one of the blacklisted keycodes 
    if (event.type == 'mousewheel' || event.which in { 40 : 0, 38 : 0, 104 : 0, 98 : 0, 32 : 0 }) { 

     //then prevent the scroll from occuring 
     return false; 
    } 
});​​​ 

这里是一个演示:http://jsfiddle.net/9Z2ru/

我尝试禁用滚动通过returnscroll活动荷兰国际集团false但不能以这种方式被禁止(在至少在Chrome 18中,尽管我怀疑大多数(如果不是全部的话)浏览器是相同的)。

+0

Altho。,我意识到我的问题是溢出,这解决了实际问题。谢谢。在这里,有一个upvote和答案标记 – w8ph 2012-04-09 23:29:47