Look at my widget:https://github.com/simo101/ScrollToAnchor. You probably aren't scrolling the right region or the anchor hasn't loaded yet.
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.