jQuery scrollTop() doesn't seem to work in Safari or Chrome (Windows)

Posted by Pointy on Stack Overflow See other posts from Stack Overflow or by Pointy
Published on 2009-12-02T01:14:49Z Indexed on 2010/05/03 1:38 UTC
Read the original article Hit count: 628

Filed under:
|
|

I've got a simple setup to allow a "help"-style window to be loaded and scrolled to a particular point on the page. More or less the code looks like this:

var target = /* code */;
target.offsetParent().scrollTop(target.offset().top - fudgeValue);

The target of the scroll and the fudge value are determined by a couple of hints dropped on the page, and I'm having no problems with that part of this mechanism anywhere. In Firefox and IE8, the above code works exactly like I want: the scrolled box (in this case, the page body) correctly scrolls the contained stuff to the right point in the window when it's told to do so.

In Chrome and Safari, however, the call to scrollTop() apparently does nothing at all. All the numbers are OK, and the target refers to the right thing (and the offsetParent() is indeed the body element), but nothing at all happens. As far as I can tell from googling around, this is supposed to work. Is there something funny about the renderer under Safari and Chrome?

This is jQuery 1.3.2 if that matters.

Test page: http://gutfullofbeer.net/scrolltop.html

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript