Bugfix for scrolling to a new page in JS