Class OpenLink Stay organized with collections Save and categorize content based on your preferences.
Page Summary
OpenLink represents an action to open a link with options.
It is available for Google Workspace add-ons and Google Chat apps.
OpenLink can be configured to open links in an overlay or full screen, and to reload the add-on or do nothing when closed.
Add-ons cannot detect window state or update if a link has the Cross-Origin-Opener-Policy (COOP) header enabled when trying to reload.
Key methods for OpenLink include
setOnClose,setOpenAs, andsetUrl.
Represents an action to open a link with some options.
Available for Google Workspace add-ons and Google Chat apps.
// A button that opens as a link in an overlay and// requires a reload when closed.constbutton=CardService.newTextButton().setText('This button opens a link in an overlay window').setOpenLink(CardService.newOpenLink().setUrl('https://www.google.com').setOpenAs(CardService.OpenAs.OVERLAY).setOnClose(CardService.OnClose.RELOAD_ADD_ON),);// An action response that opens a link in full screen and// requires no action when closed.constactionResponse=CardService.newActionResponseBuilder().setOpenLink(CardService.newOpenLink().setUrl('https://www.google.com').setOpenAs(CardService.OpenAs.FULL_SIZE).setOnClose(CardService.OnClose.NOTHING),).build();
Note: To reload add-ons after closing a link, don't use a link withCross-Origin-Opener-Policy (COOP) header enabled. If COOP is enabled in a link, add-ons can'tdetect the window state, and the add-on card doesn't update.
Methods
| Method | Return type | Brief description |
|---|---|---|
set | Open | Sets the behavior of the URL action when the URL window or tab is closed. |
set | Open | Sets the behavior of URL when it is opened. |
set | Open | Sets the URL to be opened. |
Detailed documentation
setOnClose(onClose)
setOpenAs(openAs)
setUrl(url)
Sets the URL to be opened. The URL must match a prefixwhitelisted inthe manifest.
Parameters
| Name | Type | Description |
|---|---|---|
url | String | The URL to open. |
Return
Open — This object, for chaining.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-03 UTC.