google-app-maker

How to change window title from within Google App Maker?


How can I change the window title (i.e. text displayed on the browser tab) from within an App Maker app?

I've tried the following with a button onClick ...

document.title = 'Hello';
window.parent.document.title = 'Hello2';
window.document.title = 'Hello3';

I can retrieve those within the console after setting them, but nothing changes the browser tab text.


Solution

  • If App Script doesn't allow to do something explicitly, then most likely it is forbidden. App Script nests web apps within multiple sandboxed iframes and overrides most built-in browser objects. I had a quick look at API reference and haven't found any API to manipulate page title in runtime. The only way to set tile I found in their API is this function:

    https://developers.google.com/apps-script/reference/html/html-output#setTitle(String)

    It sets title to the output html that is sent to client. You can achieve the same result in App Maker by simple renaming your app.