That will probably be a pain to accomplish...
The behavior of jumping to an anchor within a scrollable element is to some extent undefined. Browsers are free to do as they wish as the standards don't mention it.
I'm not entierly sure tho, but I think the bugs show up if you have set overflow:hidden on the div you attempt to jump to. (To actually jump, just change the .href to "page1.html#anchorname"). The standards just say that the anchor should scroll into view, but not exactly how. If the div has enough content to make it bigger than its fixed dimensions, and overflow is set to hidden, there's a kind of conflict. overflow="hidden" tells the browser that the contents should be hidden, and that it should not be possible to manually scroll to it. But it doesn't say if the browser itself should be allowed to scroll there when it thinks its necessary (you do tell it to forcibly show what's been hidden and it takes the easiest route).
When jumping to an element, the browser looks for the first parent element of the anchor which it can scroll (the div) and does so. Sometimes it scrolls both the div and the page, offsetting the div contents from their original place, maybe even enough to hide parts of it behind other elements (which happened to me on a project I was recently involved in).
I don't think we found a good solution for this except removing overflow="hidden" (switched to an alternative 3-column layout which didn't require it).