Skip to content

Instantly share code, notes, and snippets.

@rheajt
Created June 14, 2017 15:38
Show Gist options
  • Save rheajt/84d906298dd4e6d6f06a9132d386199b to your computer and use it in GitHub Desktop.
Save rheajt/84d906298dd4e6d6f06a9132d386199b to your computer and use it in GitHub Desktop.
google apps script to open a new website in a new window
function openTab() {
var selection = SpreadsheetApp.getActiveSheet().getActiveCell().getValue();
var html = "<script>window.open('" + selection + "');google.script.host.close();</script>";
var userInterface = HtmlService.createHtmlOutput(html);
SpreadsheetApp.getUi().showModalDialog(userInterface, 'Open Tab');
}
@stndstn
Copy link

stndstn commented Oct 17, 2018

Thanks

@raulsananes
Copy link

Awesome! Worked perfectly.

@shivamragnar
Copy link

What if Spreadsheet is not the use case, suppose you have link for a Google Drive file and then you have to open that link in a new tab or window?

@mariodac
Copy link

Only works with google chrome?

@alexandreb06800
Copy link

Hello, how to open 2 url at the same time? Please

@cole-wilson
Copy link

Thanks!

@raj-anand-14
Copy link

raj-anand-14 commented May 31, 2022

  • Hi, the workaround to download Link from a cell works great.
  • How about if there is more links. Say for example I've a multiple URL's in column B, range about B1:B10.
  • How to download the data from these different URL's .
    Should we use for loop or do while for this criteria
    Note: I've replaced getActiveCell() with getRange('Cell_Reference')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment