1

I'm required to use a website for school that scrolls the page whenever you click an inputbox. Is there a way to disable JS from scrolling the page?

I've found the section of JS that does the scrolling.

  // Automatically scroll to inputs when they gain focus. Do not do this for Partner Chat, where there is only one input.
  $('#activity_shell').find('input').each(function(){
    if ($(this).attr('type') == 'text') {
      $(this).focus(function(){ $('html, body').animate({scrollTop: ($(this).offset().top) - 200}, 200); });
    }
  });

1 Answer 1

4

Use CTRL+SHIFT+K to open the developer tools. Then run the following code in the console:

window.scrollTo = window.scrollBy = window.scroll = function() {};

This replaces all JavaScript functions that can be used for scrolling with a new function that does nothing.


Since you now posted the code there is a much easier way - simply unbind the focus event that triggers the scrolling:

$('#activity_shell input:text').unbind('focus');
3
  • Hmm, that didn't work.
    – Avery3R
    Sep 30, 2013 at 0:12
  • I added the section of JS that does the scrolling.
    – Avery3R
    Sep 30, 2013 at 0:20
  • Ah.. it modifies the scrollTop property directly.. that makes it tricky. Sep 30, 2013 at 11:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .