Google Apps Script UI: Scroll to top of screen

2019-08-28 22:25发布

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)

2条回答
劳资没心,怎么记你
2楼-- · 2019-08-28 22:51

using HtmlService with IFRAME mode...

$("html, body").animate({ scrollTop: 0 }, "slow");

查看更多
Melony?
3楼-- · 2019-08-28 23:09

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).

查看更多
登录 后发表回答