+ 2

HTML Hyperlinks in GAS

Does anyone know how to create a HTML link in a Google Apps Script sidebar that links to the sheets tabs which on click keeps the user on the sheet instead of opening a new browser tab? I’m trying to create an index sidebar of all sheet tab names that the user can use to navigate around with within the sheet.

16th Sep 2020, 7:54 PM
Luke Bangs
Luke Bangs - avatar
2 Answers
+ 1
I don't know how your code's currently (would even be interesting sharing this). But, have you considered using an iFrame to attach the content in your page? More information at: https://www.sololearn.com/Discuss/1557916/how-to-use-iframe-tag Good luck.
21st Sep 2020, 12:35 PM
Lauany Reis da Silva
Lauany Reis da Silva - avatar
This is an interesting feature that I am sure I will use for another means so thank you for sharing. However it is not exactly what I need. The code I have currently is below. The issue is, the list of links it creates are linked to the correct tabs, but clicking them opens a new tab instead of just changing the current user window to the clicked tab. <!DOCTYPE html> <!-- SidebarIndex.html --> <!-- The html content file for creating the Index Sidebar. --> <!-- Include the CSS formatting. --> <?!= include('css') ?> <!-- We grab our css.html file and add it to the <head>. Only used in Apps Script. --> <!-- Add a top heading. --> <h1>Data Sheet Index:</h1> <!-- Add a button to close the menu. --> <input type="button" value="Close" onclick="google.script.host.close()" /> <!-- Add a list of all sheet names with hyperlinks. --> <ol> <?!= getSheetNames().map(function(d) { return "<li><a href='https://docs.google.com/spreadsheets/d/XXX/edit#gid=" + d[1] + "&range=A1' target='_blank'>" + d[0] + "</a></li>"; }).join(''); ?> </ol>
24th Sep 2020, 8:57 AM
Luke Bangs
Luke Bangs - avatar