Things to do in Cape Town, the Helderberg, and the Cape Winelands

Tag top

How to Scroll to the Top of a Page with Plain Old Javascript

Plain old vanilla Javascript comes equipped with two really handy functions, namely scrollBy(dx,dy) which allows you to scroll a window by the specified number of pixels and scrollTo(x,y) which forces a window to scroll to the specified co-ordinates, with the specified point referring to the top left corner of the window.

© 2021 An Exploring South African — Powered by WordPress