user-interfacegoogle-apps-script

Google Apps Script UI: Scroll to top of screen


SETUP:

Using Google Apps Script's UI (doGet) with tabPanel option. At the bottom of each panel is a "previous" and "next" button to navigate through the tabs.

ISSUE:

When activating a navigation button the viewing area remains at the bottom of the screen.

QUESTION:

What code can be used to jump to the top of the screen? (i.e. window.scrollTo(0,0)


Solution

  • Unfortunately, there's no way to interact with the browser like this. But you can control the window scrolling if you wrap up all your GUI inside your own scroll panel, instead of using the browser's one.

    Then, you can use the myScroll.setScrollPosition(y).setHorizontalScrollPosition(x).