The problem occurs essentially because the jumping to the anchor is occurring at the same time as the expanding/collapsing of a content, causing the final scroll position to not always be the correct one. Instead of using HTML anchors to jump to the anchor in question, try making use of the ontoggle event handler of the script to execute custom code at the end of an expand/collapse animation, in this case, to then scroll to the activating anchor. Specifically, try the below:
1) For all your anchor links, remove the #anchor value from the href attribute and revert it back to just executing JavaScript when clicked on. Also, give the anchor an ID with the value DIVID-anchor, where DIVID is the ID of the DIV the anchor is toggling.
Code:
<a id="archeology-anchor" href="javascript:animatedcollapse.toggle('archeology')">read more</a>
2) Inside the initialization code of the script in the HEAD section of your page, populate the ontoggle event handler with the following custom code:
Code:
animatedcollapse.ontoggle=function($, divobj, state){ //fires each time a DIV is expanded/contracted
//$: Access to jQuery
//divobj: DOM reference to DIV being expanded/ collapsed. Use "divobj.id" to get its ID
//state: "block" or "none", depending on state
if (state == "block"){
var anchorid = divobj.id + "-anchor"
if ($('#' + anchorid).length == 1)
$('#' + anchorid).get(0).scrollIntoView()
}
}
That should do it in getting the script to scroll to the anchor of each collapsible DIV once the DIV is expanded.
Bookmarks