0

Even tho. scrollling is "no", and overflow is hidden, browsers dont show scrolls etc yet I can scroll by middle mouse button. I want user to be unable to scroll no matter what. Also, the frameset has: rows="50,*" and the stuff inside frame isnt higher than 50 height px yet again, it is scrollable for few pixels.

w8ph
  • 129
  • 1
  • 2
  • 8
  • Do you have an online example... maybe a fiddle? – Connor Apr 09 '12 at 22:45
  • http://stackoverflow.com/questions/4770025/how-to-disable-scrolling-temporarily – miqbal Apr 09 '12 at 22:46
  • you still can scroll with the keyboard pressing shift+arrow down. – magallanes Apr 09 '12 at 23:01
  • see this web page, eksisozluk.com , where middle mouse seems to work(cursor changes) yet you cant scroll the top frame. that is exactly what I want to achieve. I have looked at /top.js but it is beyond my understanding and doubt if the trick is in even there, if there is even a trick or am I doing something wrong ? . About fiddle, you can just look at eksisozluk – w8ph Apr 09 '12 at 23:04
  • just disable middle mouse button by javascript – EmRa228 Apr 09 '12 at 22:54
  • And what about my arrow keys? A hack at best. – Ed S. Apr 09 '12 at 23:06

1 Answers1

2

In the iframe add this code:

$(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;
    }
});​​​

Here is a demo: http://jsfiddle.net/9Z2ru/

I tried disabling scrolling by returning false for the scroll event but it cannot be disabled in this way (at least in Chrome 18, although I suspect most, if not all, browsers are the same).

Jasper
  • 75,717
  • 14
  • 151
  • 146
  • Altho., I realized my problem was with overflow, this fixes the actual issue. Thanks. here, have an upvote and answer mark – w8ph Apr 09 '12 at 23:29