简体   繁体   中英

Google Apps Script HTML Services: Scroll to top of window

I have a form that once submitted I would like it to scroll the browser up to the top so the use can see the 'Thanks for submitting!' message. I have tried:

window.scrollto(0,0);

and also:

$('#wrapper').scrollTop();

Does Google allow you to reposition the browser in HtmlServices? Anyone have a working example?

Regards,

Shawn

I have done this with anchor for backwards compatibility ...

<a id='top' href="#"></a>

Then in javascript :

window.location.hash = '#top';

You can also use scroll into view :

var div = document.getElementById("top");
div.style.display = 'block';
div.scrollIntoView(true);

Hope it help you

如果您通过 iframe 实现表单,只需在标签中添加以下内容:

onload="window.scrollTo(0,0)"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM