However, it doesn't work in firefox. You will not see any action taken after the line is executed. To workaround the issue, you can use the following code:
var yPos = el.offsetTop;
var tempEl = el.offsetParent;
while (tempEl != null)
yPos += tempEl.offsetTop;
tempEl = tempEl.offsetParent;
getOffsetTop method is used to get the accurate top pixel of any element.
Here, window.scrollTo has two parameters. The first one represents offsetX and the second one represents offsetY. Here we only use the second parameter to scroll to the top border of the target control.