Look at my widget:https://github.com/simo101/ScrollToAnchor. You probably aren't scrolling the right region or the anchor hasn't loaded yet.
In JavaScript, you can use
document.getElementById('id_of_object').scrollIntoView();
to get a specific element scrolled into view. Unfortunately it is not a smooth scroll, that can only be done when using Firefox or using a library like jQuery.
Instead of getElementById(), you probably know a way to find your object using your widget.