2012-04-09 57 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