Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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); });
    }
  });
share|improve this question

1 Answer 1

up vote 2 down vote accepted

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');
share|improve this answer
    
Hmm, that didn't work. –  MMavipc Sep 30 '13 at 0:12
    
I added the section of JS that does the scrolling. –  MMavipc Sep 30 '13 at 0:20
    
Ah.. it modifies the scrollTop property directly.. that makes it tricky. –  ThiefMaster Sep 30 '13 at 11:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.