How to Open a Website in New Window from Google Sheets Menu
Let’s say you have built an add-on for Google Sheets that adds a new menu item to the sheets UI. You would now like to add an option in the menu that, when clicked, will redirect the user to your website without the user having to click any other button. For instance, in this demo Google Sheet , we have a parent menu and a sub-menu that opens the underlying website in the new window. 1. Add Menu in Google Sheets As a first step, we’ll add a custom menu in the Google Sheet and invoke it from the onOpen function so the menu is always available when a user opens your Google Sheet. const onOpen = ( ) => { const ui = SpreadsheetApp . getUi ( ) ; const parentMenu = ui . createMenu ( '👩🏻💼 Digital Inspiration' ) ; parentMenu . addItem ( 'Visit our website' , 'openWebsite' ) ; parentMenu . addToUi ( ) ; } ; 2. Add HTML for Website Redirection Create a new file url.html in the Apps Script editor and add the following code. Th...