views:

8

answers:

1

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  A: 

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.

meder
I'm not in control of the scrolling; I'm trying to rely on the browser's `#fragment` URL portion handling.
chaos
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
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.
meder
Meaning I doubt you'll be able to rely on the native browser's scrolling mechanism at least in IE.
meder
Resolved the issue by using jQuery scrollTo post-load when the browser is IE, so accepting this answer.
chaos