0

I'm having a problem with IE where it doesn't scroll to a fragment (#foo on the URL) when the page loads. The anchor for the fragment is part of the base HTML, it isn't dynamic or anything. The page is pretty heavy. If I go into the location bar and hit enter, it scrolls to the anchor as expected (and as observed in other browsers). Behavior is observed on IE 7 and IE 8. Anybody run into this and have a workaround?

1 Answer 1

1

Have you tried delaying the scrolling action until say, the window load event instead of the DOM ready event? That way it might be more precise in shifting downwards and calculating where it needs to go.

A demo or some code would help debugging obviously.

5
  • I'm not in control of the scrolling; I'm trying to rely on the browser's #fragment URL portion handling.
    – chaos
    Commented Aug 9, 2010 at 15:00
  • As to a demo, I can't replicate it on simpler cases (so it seems to be to do with the page's size/complexity), so packaging up something to play with isn't working out. The relevant code is nothing but <a name="foo">Foo</a> and <a href="/somepage#foo">Foo</a>.
    – chaos
    Commented Aug 9, 2010 at 15:04
  • I think the last time I had to do this, I noticed it in IE as well and I implemented Flesler's scrollTo plugin for IE only, also had to rely on setTimeout to delay it a bit on window load. Commented Aug 9, 2010 at 15:05
  • Meaning I doubt you'll be able to rely on the native browser's scrolling mechanism at least in IE. Commented Aug 9, 2010 at 15:13
  • Resolved the issue by using jQuery scrollTo post-load when the browser is IE, so accepting this answer.
    – chaos
    Commented Aug 14, 2010 at 21:19

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